Building a Friends Networking Website


Someone has rightly said:

 

"A friend in need is a friend indeed"

 

In our life, friends are so precious that we don't want to forget them. But the problem is how we will remember them. Currently we can see so many social networking sites. So I got an idea of making such a site for my friends. Here in this site any user can see all registered user but if you want to visit the profile then you have to login in this site. First make your own profile and after it you can visit any user profile. While visiting the profile if you want to make this user as a friend then you can make. After this you can visit all friend list and profile from your account.

 

Design consideration has been left out in this project. The purpose is to have the functionality rather than design.

 

To use this project just attach the database which I stored in zip file and change the connection string in web.config file.

 

Let see the all pages used in this site:


This is the first page will show when user will run the application. Here on this page we can see all registered users:

AllRegisteredUsers.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AllRegisteredUsers.aspx.cs" Inherits="AllRegisteredUsers" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>All Registered Users</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

     <table cellpadding="0" cellspacing="0" width="90%" border="0" align="center" Background="BackGround.jpg">

       <tr><td> <asp:Label ID="lblerror" ForeColor="Red" runat="server" Font-Bold="true">

                </asp:Label>

       </td></tr>

       <tr> <td height="10px"> </td> </tr>

       <tr><td height="10px"></td></tr>

   

       <tr> <td align="center">

           <marquee> <asp:Label ID="Label1" ForeColor="blue" runat="server" Font-Bold="true" Text="All Registered User" Font-Size="18pt">

                     </asp:Label>

           </marquee>

       </td></tr>

       <tr><td>

            <table cellpadding="0" cellspacing="0" width="90%" align="center">

            <tr> <td align="right">

            <asp:LinkButton ID="MyAccount" runat="server" Visible="false" Text="My Account" OnClick="MyAccount_Click">

            </asp:LinkButton>

       </td></tr>

              <tr><td height="10px"> </td></tr>

              <tr><td align="center">

                   <asp:DataGrid ID="GridAllRecord" runat="server"  AutoGenerateColumns="false" Width="90%"

                   DataKeyField="RegistrarionID" PagerStyle-HorizontalAlign ="Center"  BorderStyle="ridge"

                   GridLines="Both" BorderWidth="2px" BorderColor ="white" BackColor="white" CellPadding="3"

                   CellSpacing="1" OnEditCommand="EditAddress"  OnDeleteCommand="AddressDelete"

                   OnItemCommand="Grid_ItemCommand" AllowSorting="true" PageSize="5"

                   OnPageIndexChanged= "GridAllRecord_PageIndexChanged" AllowPaging="true">

                  

                   <FooterStyle ForeColor="Black" BackColor="#C6C3C6"> </FooterStyle>

                   <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#A53A6A"> </HeaderStyle>

                   <FooterStyle BackColor="beige" />

                   <PagerStyle Font-Bold="true" Mode=NumericPages Font-Underline="true"/>

                   <Columns>

                     <asp:BoundColumn DataField=RegistrarionID HeaderText="ID" Visible="false">

                      <ItemStyle BackColor="graytext" />

                      <HeaderStyle BackColor="graytext" />

                     </asp:BoundColumn>

                    

                     <asp:TemplateColumn HeaderText="First Name">

                       <ItemTemplate>

                        <asp:LinkButton ID="lnkName" runat="server" ToolTip="Click Here To See The Profile"  Text='<%#DataBinder.Eval(Container.DataItem,"FirstName") %>' CommandName="RecordShow">

                        </asp:LinkButton>

                       </ItemTemplate>

                     </asp:TemplateColumn>

                    

                     <asp:BoundColumn DataField=LastName HeaderText="Last Name">

                       <ItemStyle BackColor=GhostWhite />

                     </asp:BoundColumn>

                    

                     <asp:BoundColumn DataField=WebPage HeaderText="Web Page">

                      <ItemStyle BackColor=GhostWhite />

                     </asp:BoundColumn>

                    

                     <asp:BoundColumn DataField=AboutYourSelf HeaderText="My Self">

                      <ItemStyle BackColor=GhostWhite />

                     </asp:BoundColumn>

                    

                     <asp:BoundColumn DataField=Interest HeaderText="Interest">

                      <ItemStyle BackColor=GhostWhite />

                     </asp:BoundColumn>

                    

                     <asp:ButtonColumn  CommandName="DeleteAddress" HeaderText="Delete Address" Text="Delete">

                     </asp:ButtonColumn>

                    

                   </Columns>

                  </asp:DataGrid>

                 </td></tr>

                 <tr><td height="20px"></td></tr>

              <tr><td align="Right">

                <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" Width="250px" Height="50px" />

                   <br /> <br />

                  <asp:Button ID="Button1" runat="server" Text="New User" OnClick="btnRegister_Click" Width="250px" Height="50px" />

              </td></tr>

                </table>

              </td></tr>

             

            <tr><td height="200px"> </td></tr>

        </table>

      </div>

   </form>

 </body>

</html>

AllRegisteredUsers.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class AllRegisteredUsers : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            AllRecord();

            if(!object.Equals(Session["LoginID"], null))

            {

                MyAccount.Visible = true;             

            }

        }

    }

 

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    SqlDataAdapter da;

    DataSet ds = new DataSet();

 

    public void AllRecord()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "Select RegistrarionID,FirstName,LastName,WebPage,AboutYourSelf,Interest from Registration";

        //cmd.CommandText = "select * from Registration";

        da = new SqlDataAdapter(cmd);

        cmd.Connection = con;

        da.Fill(ds);      

        con.Open();

        cmd.ExecuteNonQuery();

        GridAllRecord.DataSource = ds;

        GridAllRecord.DataBind();        

    }

 

    public void AddressDelete( object sender, DataGridCommandEventArgs e)

    {

        if (!object.Equals(Session["LoginID"], null))

        {

            if (Session["LoginID"].ToString() == "rahulSaxena")

            {

                int User_Id = int.Parse(e.Item.Cells[0].Text);

                con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

                cmd.CommandText = "delete from Registration where RegistrarionID='" + User_Id + "'";

                cmd.Connection = con;

                con.Open();

                cmd.ExecuteNonQuery();

                con.Close();

            }

            else

            {

                lblerror.Text = "You can't Delete the profile";

            }

          

        }

        else

        {

            Response.Redirect("Default.aspx");

        }
    }

 

    public void EditAddress(object sender, DataGridCommandEventArgs e)

    {

 

    }

 

    public void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)

    {

        if (e.CommandName == "RecordShow")

        {

            if (!object.Equals(Session["LoginID"], null))

            {

                int User_Id = int.Parse(e.Item.Cells[0].Text);

                string Friend_name = e.Item.Cells[1].Text;

                Session["ShowProfile"] = User_Id;

                Session["Friend_Name"] = Friend_name;

                Response.Redirect("MakeFriend.aspx");

            }

            else

            {

                Response.Redirect("Default.aspx");

            }

        }

        else

            if (e.CommandName == "DeleteAddress")

        {

            if (!object.Equals(Session["LoginID"], null))

            {

                if (Session["LoginID"].ToString() == "RahulSaxena")

                {

                    int User_Id = int.Parse(e.Item.Cells[0].Text);

                    con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

                    cmd.CommandText = "delete from Registration where RegistrarionID='" + User_Id + "'";

                    cmd.Connection = con;

                    con.Open();

                    cmd.ExecuteNonQuery();

                    con.Close();

                }

                else

                {

                    lblerror.Text = "You can't Delete the profile";

                }

 

            }

            else

            {

                Response.Redirect("Default.aspx");

            } 

        }

    }

 

    public void GridAllRecord_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)

    {

        GridAllRecord.CurrentPageIndex = e.NewPageIndex;

        AllRecord();

    }

 

    public void MyAccount_Click(object sender, System.EventArgs e)

    {

        Response.Redirect("MyAccount.aspx");

    }

 

    protected void btnLogin_Click(object sender, EventArgs e)

    {

        Response.Redirect("Default.aspx");

    }

 

    protected void btnRegister_Click(object sender, EventArgs e)

    {

        Response.Redirect("Login.aspx");

    }

}




Figure 1: All Registered Users.

Now if any registered user want to login to the site then here is the Login page:

DefaultLogin.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Login</title>

</head>

<body>

  <form id="form1" runat="server">

   <div>

    <table  id="tblSendMail" cellspacing="1" cellpadding="5" width="100%" runat="server" background="BackGround.jpg" >

      <tr><TD class="TextBlack">

         &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;

          </TD><TD></TD>

          <td  align="left">

            <asp:Label ID="lblError" runat="server" CssClass="redtext" Visible="False" Font-Bold="True">

            </asp:Label>

                  <asp:Label ID="statusLabel" runat="server" CssClass="redtext" Visible="False" Font-Bold="True">

                  </asp:Label>&nbsp;

                </td>

            </tr>

            <tr> <td> </td><td> </td>

                 <td> <marquee> <asp:Label ID="lblLoginmsg" runat="server" Text="Please Login"  Font-Bold="true" Font-Size="20pt" ForeColor="#66ffcc">

                                </asp:Label>

                 </marquee></td></tr>

            <tr>

             <TD class="TextBlack">

        &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

       </TD>

       <td align="right" valign="middle">

        <asp:Label ID="lbllogin" runat="server" Text="Login ID" ForeColor="Red" >

        </asp:Label><span class="redtext">*</span>

       </td>

       <td align="left">

        <asp:textbox id="txtLoginId" runat="server" CssClass="NormalTextBox" Width="270px">

        </asp:textbox>

       </td>

       </tr>

    

       <tr>

         <TD></TD>

         <td align="right" valign="middle">

         <asp:Label ID="lblpassword" CssClass="logintext" runat="server" Text="Password" ForeColor="Red">

         </asp:Label><span class="redtext">*</span>

         </td>

         <td align="left">

          <asp:textbox id="txtPassword" runat="server" CssClass="NormalTextBox" Width="270px" TextMode="Password">

          </asp:textbox>

         </td>  

       </tr>

    

       <tr>

        <td></td><td> </td>

        <td align="left" class="GrayFont">

         <asp:CheckBox ID="chkBoxRemember" runat="server" Checked="True" CssClass="GrayFont" Text="Remember Me?    |"/>

         <asp:LinkButton ID="lnkforget" runat="server" Text="Forgot Your Password ?" OnClick="lnkforget_Click" CssClass="HeaderLink1">

         </asp:LinkButton> &nbsp; <br />

               &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;New user&nbsp;

         <asp:LinkButton ID="lnkBtnRegisterHere" runat="server" CssClass="HeaderLink1" Font-Bold="False" OnClick="lnkBtnRegisterHere_Click">

           Register Here</asp:LinkButton>

         </td>

      </tr>     

      <tr> <TD></TD> <td></td>

           <td align="left">

            <asp:button id="btnLogin" runat="server" CssClass="NormalButton" Text="Login" Width="121px" OnClick="btnLogin_Click" Font-Bold="True">

            </asp:button>

             &nbsp;

             <asp:button id="Button1" runat="server" CssClass="NormalButton" Text="Home Page" Width="121px" OnClick="btnHomePage_Click" Font-Bold="True">

            </asp:button>

           </td>

            </tr>

            <tr><td height="25px"> </td></tr>        

            </table>

     </div>

   </form>

  </body>

</html>

DefaultLogin.aspx.cs

using
System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

 

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    SqlDataReader dr;

    protected void btnLogin_Click(object sender, EventArgs e)

    {

        if (funCheck())

        {

            con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

            cmd.CommandText = "select User_LoginId from UserIDInformation where User_LoginId='" + txtLoginId.Text + "'";

            cmd.Connection = con;

            con.Open();

            dr = cmd.ExecuteReader();

            if (dr.Read())

            {

                Session["LoginID"] = txtLoginId.Text;

                Response.Redirect("MyAccount.aspx");

              

            }

            else

            {

                Response.Redirect("Login.aspx");

            }

            con.Close();
        }

 

    }

    protected void lnkforget_Click(object sender, EventArgs e)

    {

 

    }

    protected void lnkBtnRegisterHere_Click(object sender, EventArgs e)

    {

        Response.Redirect("Login.aspx");

 

    }

 

    private bool funCheck()

    {

        string sMessage = "Enter: ";

        bool bCheck = false;

 

        if (txtLoginId.Text == "")

        {

            sMessage += " UserID";

            bCheck = true;

        }

        if (txtPassword.Text == "")

        {

            if (bCheck)

                sMessage += "/Password ";

            else

                sMessage += "Password ";

            bCheck = true;

        }

        if (bCheck == true)

        {

            lblError.Visible = true;

            lblError.Text = sMessage;

            return false;

        }

        else

            return true;

    }

    protected void btnHomePage_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

}



Figure 2: Login Page

If any user wants to register to this site then he/she have to follow Registration process, like as:


Login.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Register login</title>

</head>

<body>

    <form id="form1" runat="server">

     <div>

     <table id="Table2" cellSpacing="0" cellPadding="0" width="90%"  align="center" border="0"  bgcolor="#ffcccc">

             <tr><td height="20px"></td> </tr>

             <tr> <td vAlign="top" class="graytext" height="10">

                   <table cellSpacing="0" cellPadding="0" border="0" width="85%" align="center">

             <tr width="100%">

               <td colspan=5>

                <asp:label id="lblError" runat="server" Font-Bold="True" ForeColor="Red">

                </asp:label>

                     <asp:label id="lblEmailError" runat="server" ForeColor="Red" Font-Bold="True"></asp:label>

                     </td>

                   </tr>

                  

                   <tr><td height="20px"></td> </tr>

                   <tr> <td height="40px" align="center" colspan=5 width="100%">

                        <asp:Label ID="lblMessage" runat="server"

                              Text="Please fill all the information in the fields given below and the fields

                              marked with an asterisk" ForeColor="Blue" Font-Bold="true" Font-Size="16px"> </asp:Label>

                        <asp:Label ID="lblhead" runat="server" ForeColor="Red" Text="(*)"></asp:Label>

             <asp:Label ID="lblmandatry" runat="server" ForeColor="Blue" Text="are mandatory." Font-Bold="true">

             </asp:Label>  

           </td>

                   </tr>

                  

                    <tr>

                     <td height="18px" colspan=5>

                     </td>

                    </tr>

                  

                    <TR height=30><td width="5%"></td>

                     <TD  align="left" >

             <span style="color: red">*</span>

               <asp:label id="LabelUserId" runat="server" Text="User ID"

                      Font-Bold="true"> </asp:label>

          </TD>   

                     <TD vAlign="middle"  class="gray" align="left" colspan=4 style="height: 30px" >

                      <asp:textbox id="TextBoxUserId" runat="server" CssClass="NormalTextBox" Width="180px" MaxLength="50">

                      </asp:textbox>&nbsp;

                            User Id cannot have space in between!

                             <asp:requiredfieldvalidator id="RFVUserId" runat="server" ErrorMessage="UserId"

                                 ControlToValidate="TextBoxUserId" Display="None">User ID </asp:requiredfieldvalidator>

                                        <asp:RegularExpressionValidator ID="revId" runat="server" ControlToValidate="TextBoxUserId"

                                                ErrorMessage="Invalid UserId" Display="None" ValidationExpression="^([a-zA-Z0-9-_]+[\s]*)$">

                                        </asp:RegularExpressionValidator>         

                </TD>

               </TR>

                   <tr><td height="10px"></td></tr>

                    <tr height=30><td width="5%"></td>

                     <TD  align="left" valign="top" >

               <span style="color: red">*</span><asp:label id="Label1" runat="server"   Font-Bold="true">

                E-Mail Address</asp:label> </TD>

                     <TD vAlign="top" align="left" class="gray" colspan=4 >

                        <asp:textbox id="txtBoxUserEMail" runat="server" CssClass="NormalTextBox" Width="180px" MaxLength="50">

                         </asp:textbox>&nbsp;

                  Enter valid &amp; unique Email address

             <asp:requiredfieldvalidator id="RFVUserEMail" runat="server" ErrorMessage="EMail Address"

                ControlToValidate="txtBoxUserEMail" Display="None" CssClass="redtext">User EMail

             </asp:requiredfieldvalidator>

                                                                            

                             <asp:regularexpressionvalidator id="REVUserEMail" runat="server" ErrorMessage="Enter Correct E-Mail"

                                ControlToValidate="txtBoxUserEMail" Display="None"

                                ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

                                CssClass="redtext">User EMail </asp:regularexpressionvalidator> </TD>

                    </tr>

                   <tr><td height="10px"></td></tr>

                   <TR height=30><td width="5%"> </td>

                    <TD  align="left" valign="top">

            <span style="color: red">*</span>

            <asp:label id="LabelPassword" runat="server" Font-Bold="true" > Password </asp:label>

         </TD>

                    <TD  class="gray" align="left" colspan=4 vAlign="top">

                        <asp:textbox id="TextBoxPassword" runat="server" CssClass="NormalTextBox" Width="180px"

                         TextMode="Password" MaxLength="15"></asp:textbox>

                        &nbsp; 4 to 15 letters only. Capitalization matters!&nbsp;

             <asp:requiredfieldvalidator id="RFVPassword" runat="server" ErrorMessage="Password"

                 ControlToValidate="TextBoxPassword" Display="None"> </asp:requiredfieldvalidator> </TD>

         </TR>

                   <tr><td height="10px"></td></tr>

                   <tr height=30><td width="5%"></td>        

                    <TD  align="left" valign="top" > <span style="color: red">*</span>

                    <asp:Label id="LabelCPassword" runat="server" Font-Bold="true"> Re-type Password</asp:Label> </TD>

                    <TD   align="left" class="gray" colspan=3 vAlign="top" ><asp:textbox id="TextboxCPassword" runat="server"

                       CssClass="NormalTextBox" Width="180px" TextMode="Password" MaxLength="15"></asp:textbox>&nbsp;&nbsp;

                          Re-type password should match with your password

                             <asp:comparevalidator id="CVPassword" runat="server" ErrorMessage="Re-type Password doesn't match"

                                ControlToValidate="TextboxCPassword" Display="None" ControlToCompare="TextBoxPassword"

                                 CssClass="redtext"> </asp:comparevalidator>

                             <asp:regularexpressionvalidator id="revPWDRange" runat="server"

                                ErrorMessage="Password should be 4 to 15 letters & Space not allowed"

                                   ControlToValidate="TextBoxPassword" Display="None" ValidationExpression="\S{4,15}"

                                    CssClass="redtext"> </asp:regularexpressionvalidator>

            <asp:RequiredFieldValidator ID="rfvCPwd" runat="server"

               ControlToValidate="TextboxCPassword" Display="None" ErrorMessage="Re-type Password">

                 </asp:RequiredFieldValidator>

         </TD>

                   </TR>

                   <tr><td height="10px"></td></tr>

                   <tr><td width="10%"></td>

                    <TD style="height: 18px"></TD>

                    <TD vAlign="middle" align="left" style="height: 18px;">

                       <asp:button id="ButtonSubmit" runat="server" CssClass="NormalButton" Width="100"

                          Text="Register Me" OnClick="ButtonSubmit_Click"> </asp:button> &nbsp;

                    <asp:button id="ButtonCancel" runat="server" CssClass="NormalButton"

                       Width="100" Text="Cancel" CausesValidation="False" OnClick="ButtonCancel_Click">

                       </asp:button>

                    </TD>

              </TR>      

             

              <tr><td height="20px"></td></tr>                

            </table>

           </td>

    </tr>          

   </TABLE>

    <asp:validationsummary id="ValidationSummary1" runat="server"

      ShowSummary="False" ShowMessageBox="True" HeaderText="Check entries:" Height="30px">

    </asp:validationsummary>

   

    </div>

    </form>

</body>

</html>


Login.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

using System.Net.Mail;

using System.Drawing;

using System.Data.SqlClient;

 

public partial class Login : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    DataSet ds = new DataSet();

    SqlDataAdapter da;

    SqlDataReader dr;

    protected void ButtonSubmit_Click(object sender, EventArgs e)

    {

        int result = UserStatus();

        if (result == 1)

        {

            lblEmailError.Text = "User All Ready Exists";

        }

        else if (result == 0)

        {

            Session["User_ID"] = TextBoxUserId.Text;

            Session["Email"] = txtBoxUserEMail.Text;

            lblEmailError.Text = "SucessFully Registered";

            Response.Redirect("SelfRegistration.aspx");

           

        }

 

    }

    protected void ButtonCancel_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

 

    public int UserStatus()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "select User_LoginId from UserIDInformation where User_LoginId='" + TextBoxUserId.Text + "'";

        cmd.Connection = con;

        con.Open();

        dr = cmd.ExecuteReader();

        if (dr.Read())

        {

            return 1;

        }

        else

        {

            con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

            cmd.CommandText = "insert into UserIDInformation (User_LoginId,User_Email,Password) values ('" + TextBoxUserId.Text + "','" + txtBoxUserEMail.Text + "','" + TextBoxPassword.Text + "') ";

            cmd.Connection = con;

            con.Open();

            cmd.ExecuteNonQuery();

            con.Close();

            return 0;

        }

        con.Close();

 

    }

}




Figure 3: Make a userID.

After this the user will be rdirected to SelfRegistration:

SelfRegistration.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelfRegistration.aspx.cs" Inherits="SelfRegistration" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Registration</title>

</head>

<body>

    <form id="form1" runat="server">

      <div>

       <table cellpadding="0" cellspacing="0" width="70%" align="center" border="0" >

         <tr> <td align="center" bgcolor="#33cccc" style="height: 19px">

              <asp:Label ID="lblWelcome" runat="server" Text="Registration Form" Font-Bold="true"

                 ForeColor="#0000ff">

               </asp:Label>

         </td></tr>

         <tr><td height="5px"> </td></tr>

         <tr><td>

               <asp:Label ID="lblSucessfullyAdded" runat="server" Text="SucessFully Added"

                Visible="false" ForeColor="green" Width="170px"> </asp:Label>

         </td></tr>

         <tr><td><table width="100%"  background=BackGround.jpg>

                   <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblName" runat="server" Text="First Name" Width="170px"

                           Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtFirstName" runat="server">

                          </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="LblMiddleName" runat="server" Text="Middle Initial" Width="170px"

                           Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtMiddleName" runat="server">

                          </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblLastName" runat="server" Text="Last Name" Width="170px"

                           Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtLastName" runat="server"> </asp:TextBox>

                  </td></tr>

                  

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblwebPage" runat="server" Text="Web Page Name" Width="170px"

                          Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtWebPage" runat="server">

                    </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td> <asp:Label ID="lblEMail" runat="server" Text="E-Mail" Width="170px" Font-Bold="true"

                           ForeColor="blue"></asp:Label>

                        <asp:TextBox ID="txtEMail" runat="server" Enabled="false">

                         </asp:TextBox>

                  </td></tr>

                                                   

                  <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblAboutYourSelf" runat="server" Text="About YourSelf" Width="170px"

                          Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtAboutAyourSelf" runat="server">

                         </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblInterest" runat="server" Text="Interest" Width="170px"

                          Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtInterest" runat="server"> </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblFavouritePassTime" runat="server" Text="Favourite Pass Time"

                          Width="170px" Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtFavouritePassTime" runat="server">

                         </asp:TextBox>

                  </td></tr> 

                  

                  <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblFavouriteMovie" runat="server" Text="Favourite Movie" Width="170px"

                           Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteMovie" runat="server"> </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%">  </td>

                       <td>

                        <asp:Label ID="lblFavouriteActor" runat="server" Text="Favourite Actor" Width="170px" Font-Bold="true" ForeColor="blue"></asp:Label>

                        <asp:TextBox ID="txtFavouriteActor" runat="server"></asp:TextBox>

                   </td></tr>

                   

                   <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblFavouriteActress" runat="server" Text="Favourite Actress"

                          Width="170px" Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteActress" runat="server">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"> </td>

                       <td>

                        <asp:Label ID="lblBestPlaceToLive" runat="server" Text="Best Place To live" Width="170px" Font-Bold="true" ForeColor="blue"></asp:Label>

                        <asp:TextBox ID="txtBestPlace" runat="server"></asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblUnforgettableMoment" runat="server" Text="UnForgettable Moment"

                          Width="170px" Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtUnForgettableMoment" runat="server" TextMode="MultiLine">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine1" runat="server" Text="Address Line 1" Width="170px"

                          Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine1" runat="server">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine2" runat="server" Text="Address Line 2" Width="170px"

                         Font-Bold="true" ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine2" runat="server">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblCity" runat="server" Text="City" Width="170px" Font-Bold="true"

                         ForeColor="blue"> </asp:Label>

                        <asp:TextBox ID="txtCity" runat="server"> </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblCountry" runat="server" Text="Country" Width="170px"

                          Font-Bold="true" ForeColor="blue"> </asp:Label>

                <asp:dropdownlist id="DdlistCountry" runat="server" CssClass="NormalDropDown" BackColor="White" Width="206px">

         <asp:ListItem Value="Not Applicable">--Select--</asp:ListItem>

          <asp:ListItem Value="Not Applicable">--Select--</asp:ListItem><asp:ListItem Value="Afghanistan">Afghanistan</asp:ListItem>

                                                                    <asp:ListItem Value="Algeria">Algeria</asp:ListItem>

                                                                    <asp:ListItem Value="Albania">Albania</asp:ListItem>                      

                                                                     

                                                          </asp:dropdownlist>

                   </td></tr>

                   <tr><td height="10px"></td></tr>

         </table></td></tr>

        

         <tr><td align="center">

                <asp:Label ID="lblRegisterHere" runat="server" Text="For Register Click Here "

                      Font-Bold="true" Width="190px">

                      </asp:Label>

                <asp:Button ID="btnRegister" runat="server" Text="Register" OnClick="RegisterMe_Click"

                 Font-Bold="true" Width="190px" ForeColor="Blue" />  

         </td></tr>

         <tr><td height="10px"></td></tr>

    </table>

   

    </div>

    </form>

</body>

</html>

SelfRegister.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class SelfRegistration : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        string EMalil = Session["Email"].ToString();

        string USer_LoginID = Session["User_ID"].ToString();

        txtEMail.Text = EMalil;

    }

    SqlConnection con;

    SqlCommand cmd=new SqlCommand();

    SqlDataAdapter da;

 

    protected void RegisterMe_Click(object sender, EventArgs e)

    {

        RegisterUser();

         lblSucessfullyAdded.Visible = true;

txtFirstName.Text = "";

        txtCity.Text = "";

             txtEMail.Text = "";

           txtFavouriteActor.Text = "";

          txtFavouriteActress.Text = "";

          txtInterest.Text = "";

    ;       txtUnForgettableMoment.Text = "";

        txtBestPlace.Text = "";

        txtAddressLine1.Text = "";

        txtAddressLine2.Text = "";

        txtAboutAyourSelf.Text = "";

        Response.Redirect("Message.aspx");

    }

 

    public void RegisterUser()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "Insert into Registration (Register_User_LoginID, Register_EMail, FirstName,  MiddleName, LastName,WebPage, AboutYourSelf, Interest, FavouritePassTime, Actor,Actress, FavouriteMovie, BestPlace, Moment, Address1, Address2,City, Country) values ('" + Session["User_ID"].ToString() + "','" + Session["Email"].ToString() + "','" + txtFirstName.Text + "','" + txtMiddleName.Text + "','" + txtLastName.Text + "','" + txtWebPage.Text + "','" + txtAboutAyourSelf.Text + "','" + txtInterest.Text + "','" + txtFavouritePassTime.Text + "','" + txtFavouriteActor.Text + "','" + txtFavouriteActress.Text + "','" + txtFavouriteMovie.Text + "','" + txtBestPlace.Text + "','" + txtUnForgettableMoment.Text + "','" + txtAddressLine1.Text + "','" + txtAddressLine2.Text + "','" + txtCity.Text + "','" + DdlistCountry.SelectedValue + "')";

        cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        con.Close();

    }

}




Figure 4: Self registeration page.

After Sucessfully Registration the message page will come like this:


Message.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Message.aspx.cs" Inherits="Message" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Message</title>

</head>

<body>

    <form id="form1" runat="server">

     <div>

      <table cellpadding="0" cellspacing="0" width="90%" align="center" border="4">

       <tr><td height="50px"></td></tr>

       <tr><td align="center">

           <table cellpadding="0" cellspacing="0" border="0" width="90%">

             <tr><td>

                   <marquee>

                     <asp:Label ID="lblsucessfullyadded" runat="server" Font-Bold="true"

                       Font-Size="20px" Text="Sucessfuly Added" ForeColor="#00cc66">

                     </asp:Label>

                   </marquee>

              </td></tr>

             <tr><td height="50px"></td></tr>             

            <tr><td align="center">

                <asp:Button ID="btnHomePage" runat="server" Text="Home Page"  OnClick="btnHomePage_Click" />

            </td></tr>  

           </table>

       </td></tr>

     </table>

    </div>

  </form>

 </body>

</html>


Message.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

public partial class Message : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

    protected void btnHomePage_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

}



Figure 5: Successful register.

 

If user want to see the their own Account then:

MyAccount.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyAccount.aspx.cs" Inherits="MyAccount" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>My Account</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <table cellpadding="0" cellspacing="0" width="80%" bgcolor="#00ccff" align="center">

     <tr><td height="90px"></td></tr>

     <tr> <td width="20%" style="height: 19px"> </td>

          <td style="height: 19px">

          <asp:LinkButton ID="MyProfile" runat="server" Text="My Profile" Font-Bold="true"

             Font-Size="22pt" OnClick="MyProfile_Click">

          </asp:LinkButton>

     </td></tr>

    

     <tr><td height=40px></td></tr>

    

     <tr><td width="20%" style="height: 19px"></td>

          <td style="height: 19px">

          <asp:LinkButton ID="LinkButton1" runat="server" Text="All Users"  Font-Bold="true"

            Font-Size="22pt" OnClick="AllUser">

          </asp:LinkButton>

     </td></tr>

      <tr><td height=40px></td> </tr>

     <tr><td width="20%"> </td>

          <td>

          <asp:LinkButton ID="LinkButton2" runat="server" Text="My Friend"

            Font-Bold="true" Font-Size="22pt" OnClick="MyFriend">

          </asp:LinkButton>

     </td></tr>

      <tr><td height="90px"></td></tr>

    

    </table>  

    </div>

    </form>

</body>

</html>

MyAccount.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

public partial class MyAccount : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

 

    }

 

    protected void MyProfile_Click(object sender, EventArgs e)

    {

        Response.Redirect("MyProfile.aspx");

    }

 

    protected void AllUser(object sender, EventArgs e)

    {

        Response.Redirect("AllregisteredUsers.aspx");

    }

 

    protected void MyFriend(object sender, EventArgs e)

    {

        Response.Redirect("MyFriendList.aspx");

    }

}




Figure 6: My account.

If user want to see their own profile:

MyProfile.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyProfile.aspx.cs" Inherits="MyProfile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>My Profile</title>

</head>

<body>

 <form id="form1" runat="server">

   <div>

    <table background="BackGround.jpg" cellpadding="0" cellspacing="0" width="100%">

      <tr><td height="10px"> </td></tr>

      <tr><td width="25%" bgcolor="black"> </td>

          <td bgcolor="black">

            &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;

              &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;

              <asp:Label ID="lblFirstName" runat="server" ForeColor="#ff66ff" Font-Bold="true"

                 Font-Size="20pt"> </asp:Label>

              <asp:Label ID="lblLastName" runat="server" ForeColor="#ff66ff" Font-Bold="true"

               Font-Size="20pt"> </asp:Label>                

            </td></tr>

        <tr><td height="15px"></td></tr>

        <tr><td width="25%"></td>

             <td>

               <asp:Label ID="lblwebPage" runat="server" Text="Web Page Name" Width="170px" Font-Bold="true"

                   ForeColor="#333399"> </asp:Label>

               <asp:TextBox ID="txtWebPage" runat="server" ForeColor="#ff00ff">

                </asp:TextBox>

             </td></tr>

             <tr><td width="25%"></td>

                  <td>

                    <asp:Label ID="lblEMail" runat="server" Text="E-Mail" Width="170px" Font-Bold="true"

                       ForeColor="#333399"> </asp:Label>

                    <asp:TextBox ID="txtEMail" runat="server" Enabled="false" ForeColor="#ff00ff">

                     </asp:TextBox>

                  </td></tr>

                 <tr><td width="25%"> </td>

                 <td>

                   <asp:Label ID="lblAboutYourSelf" runat="server" Text="About YourSelf" Width="170px"

                     Font-Bold="true" ForeColor="#333399"> </asp:Label>

                   <asp:TextBox ID="txtAboutAyourSelf" runat="server" ForeColor="#ff00ff">

                    </asp:TextBox>

                  </td></tr>

                 <tr><td width="25%"> </td>

                     <td><asp:Label ID="lblInterest" runat="server" Text="Interest" Width="170px"

                           Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtInterest" runat="server" ForeColor="#ff00ff"> </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouritePassTime" runat="server" Text="Favourite Pass Time"

                                  Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouritePassTime" runat="server" ForeColor="#ff00ff">

                          </asp:TextBox>

                  </td></tr> 

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteMovie" runat="server" Text="Favourite Movie"

                            Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteMovie" runat="server" ForeColor="#ff00ff">

                          </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActor" runat="server" Text="Favourite Actor" Width="170px"

                          Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteActor" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActress" runat="server" Text="Favourite Actress" 

                            Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteActress" runat="server" ForeColor="#ff00ff">

                          </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblBestPlaceToLive" runat="server" Text="Best Place To live"

                           Width="170px" Font-Bold="true" ForeColor="#333399">  </asp:Label>

                        <asp:TextBox ID="txtBestPlace" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td> <asp:Label ID="lblUnforgettableMoment" runat="server" Text="UnForgettable Moment"

                          Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtUnForgettableMoment" runat="server" TextMode="MultiLine"

                       ForeColor="#ff00ff"> </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine1" runat="server" Text="Address Line 1" Width="170px"

                          Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine1" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine2" runat="server" Text="Address Line 2" Width="170px"

                          Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine2" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblCity" runat="server" Text="City" Width="170px" Font-Bold="true"

                          ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtCity" runat="server" ForeColor="#ff00ff">

                     </asp:TextBox>

                   </td></tr>

                   

                   <tr><td height="20px"></td></tr>

                   <tr><td width="25%"></td><td>

                   <asp:Button ID="btnHomePage" runat="server" Text="Home Page" Width="250px"

                     OnClick="HomePage_Click" ForeColor="#006600"/>

                    <asp:Button ID="Button1" runat="server" Text="My Friend" Width="250px"

                       OnClick="MyFriend_Click" ForeColor="#006600"/>

                   </td></tr>

                   <tr><td height="20px"> </td></tr>

          </table>   

        </div>

      </form>

    </body>

</html>

MyProfile.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class MyProfile : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        MyProfileShow();

    }

    SqlConnection con;

    SqlDataAdapter da;

    SqlCommand cmd=new SqlCommand();

    DataSet ds= new DataSet();

  

    public void MyProfileShow()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "Select * from Registration where Register_User_LoginID='" + Session["LoginID"] + "'";

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);      

        con.Open();

        cmd.ExecuteNonQuery();

        if (ds.Tables[0].Rows.Count > 0)

        {

            lblFirstName.Text = ds.Tables[0].Rows[0][3].ToString();

            lblLastName.Text = ds.Tables[0].Rows[0][5].ToString();

            txtAboutAyourSelf.Text = ds.Tables[0].Rows[0][7].ToString();

            txtAddressLine1.Text = ds.Tables[0].Rows[0][14].ToString();

            txtAddressLine2.Text = ds.Tables[0].Rows[0][15].ToString();

            txtBestPlace.Text = ds.Tables[0].Rows[0][12].ToString();

            txtCity.Text = ds.Tables[0].Rows[0][16].ToString();

            txtEMail.Text = ds.Tables[0].Rows[0][2].ToString();

            txtFavouriteActor.Text = ds.Tables[0].Rows[0][10].ToString();

            txtFavouriteActress.Text = ds.Tables[0].Rows[0][11].ToString();

            txtFavouriteMovie.Text = ds.Tables[0].Rows[0][18].ToString();

            txtFavouritePassTime.Text=ds.Tables[0].Rows[0][9].ToString();

            txtInterest.Text = ds.Tables[0].Rows[0][8].ToString();

            txtUnForgettableMoment.Text = ds.Tables[0].Rows[0][13].ToString();

            txtWebPage.Text = ds.Tables[0].Rows[0][6].ToString();

        }

        con.Close();

    }

    protected void HomePage_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

    protected void MyFriend_Click(object sender, EventArgs e)

    {

        Response.Redirect("MyFriendList.aspx");

    }

}



Figure 7: My profile.

If any user want to see any other user profile to make friend then:

MakeFriend.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MakeFriend.aspx.cs" Inherits="MakeFriend" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Make Friend</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <table cellpadding="0" cellspacing="0" width="100%" border="0">

         <tr><td width="25%" bgcolor="blue"></td><td bgcolor="blue" width="60%">

         <asp:ImageButton ID="imgMakeFriend" runat="server" OnClick="imgMakeFriendf" ImageUrl="~/f.gif" ToolTip="Add this as a Friend" />

         <asp:ImageButton ID="ImageButton1" runat="server" OnClick="imgMakeFriendr" ImageUrl="~/r.gif" ToolTip="Add this as a Friend" />

         <asp:ImageButton ID="ImageButton2" runat="server" OnClick="imgMakeFriendi" ImageUrl="~/i.gif" ToolTip="Add this as a Friend" />

         <asp:ImageButton ID="ImageButton3" runat="server" OnClick="imgMakeFriende" ImageUrl="~/e.gif"  ToolTip="Add this as a Friend"/>

         <asp:ImageButton ID="ImageButton4" runat="server" OnClick="imgMakeFriendn" ImageUrl="~/n.gif" ToolTip="Add this as a Friend" />

         <asp:ImageButton ID="ImageButton5" runat="server" OnClick="imgMakeFriendd" ImageUrl="~/d.gif" ToolTip="Add this as a Friend"/>                

         </td></tr>

    </table>

   

    <table background="BackGround.jpg" cellpadding="0" cellspacing="0" width="100%">

      <tr><td height="10px">     

      </td></tr>

      <tr><td width="25%" bgcolor="black"></td>

          <td bgcolor="black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <asp:Label ID="lblFirstName" runat="server" ForeColor="#ff66ff" Font-Bold="true" Font-Size="20pt">

               </asp:Label>

              <asp:Label ID="lblLastName" runat="server" ForeColor="#ff66ff" Font-Bold="true" Font-Size="20pt">

               </asp:Label>                

      </td></tr>

     

      <tr><td height="15px"></td></tr>

      <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblwebPage" runat="server" Text="Web Page Name" Width="170px"

                          Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtWebPage" runat="server" ForeColor="#ff00ff"> </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblEMail" runat="server" Text="E-Mail" Width="170px" Font-Bold="true"

                          ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtEMail" runat="server" Enabled="false" ForeColor="#ff00ff">

                        </asp:TextBox>

                  </td></tr>

                                                   

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAboutYourSelf" runat="server" Text="About YourSelf" Width="170px"

                         Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAboutAyourSelf" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblInterest" runat="server" Text="Interest" Width="170px" Font-Bold="true"

                         ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtInterest" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouritePassTime" runat="server" Text="Favourite Pass Time"

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouritePassTime" runat="server" ForeColor="#ff00ff"> </asp:TextBox>

                  </td></tr> 

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteMovie" runat="server" Text="Favourite Movie" Width="170px"

                         Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtFavouriteMovie" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActor" runat="server" Text="Favourite Actor" Width="170px"

                          Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtFavouriteActor" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActress" runat="server" Text="Favourite Actress" Width="170px"

                          Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtFavouriteActress" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblBestPlaceToLive" runat="server" Text="Best Place To live" Width="170px"

                          Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtBestPlace" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblUnforgettableMoment" runat="server" Text="UnForgettable Moment"

                         Width="170px" Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtUnForgettableMoment" runat="server" TextMode="MultiLine"

                         ForeColor="#ff00ff"> </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine1" runat="server" Text="Address Line 1"

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine1" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine2" runat="server" Text="Address Line 2"  

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine2" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblCity" runat="server" Text="City" Width="170px" Font-Bold="true"

                          ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtCity" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td height="20px"></td></tr>

                   <tr><td width="25%"></td><td>

                   <asp:Button ID="btnHomePage" runat="server" Text="Home Page" Width="250px"

                     OnClick="HomePage_Click" ForeColor="#006600"/> </td></tr>

                   <tr><td height="20px"></td></tr>

    </table>   

    </div>

    </form>

</body>

</html>


MakeFriend.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class MakeFriend : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {       

       friendProfile();

       string Dost_UserID = friend_User_LoginId();

    }

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    DataSet ds = new DataSet();

    SqlDataAdapter da;

    string friendUserId;

 

    public void friendProfile()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "Select * from Registration where RegistrarionID='" + Session["ShowProfile"] + "'";

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);

      

        con.Open();

        cmd.ExecuteNonQuery();

        if (ds.Tables[0].Rows.Count > 0)

        {

            lblFirstName.Text = ds.Tables[0].Rows[0][3].ToString();

            lblLastName.Text = ds.Tables[0].Rows[0][5].ToString();

            txtAboutAyourSelf.Text = ds.Tables[0].Rows[0][7].ToString();

            txtAddressLine1.Text = ds.Tables[0].Rows[0][14].ToString();

            txtAddressLine2.Text = ds.Tables[0].Rows[0][15].ToString();

            txtBestPlace.Text = ds.Tables[0].Rows[0][12].ToString();

            txtCity.Text = ds.Tables[0].Rows[0][16].ToString();

            txtEMail.Text = ds.Tables[0].Rows[0][2].ToString();

            txtFavouriteActor.Text = ds.Tables[0].Rows[0][10].ToString();

            txtFavouriteActress.Text = ds.Tables[0].Rows[0][11].ToString();

            txtFavouriteMovie.Text = ds.Tables[0].Rows[0][18].ToString();

            txtFavouritePassTime.Text=ds.Tables[0].Rows[0][9].ToString();

            txtInterest.Text = ds.Tables[0].Rows[0][8].ToString();

            txtUnForgettableMoment.Text = ds.Tables[0].Rows[0][13].ToString();

            txtWebPage.Text = ds.Tables[0].Rows[0][6].ToString();

        }

        con.Close();

    }

 

    protected void imgMakeFriendf(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    protected void imgMakeFriendr(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    protected void imgMakeFriendi(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    protected void imgMakeFriende(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    protected void imgMakeFriendn(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    protected void imgMakeFriendd(object sender, ImageClickEventArgs e)

    {

        myfriend();

    }

 

    public void myfriend()

    {

        //string Dost_UserID=friend_User_LoginId();

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "Insert into FriendRecord(Register_User_LoginID,Friend_UserLoginId,MyFriendName) values ('" + Session["LoginID"] + "','" + friend_User_LoginId() + "','" + FriendName() + "')";

        cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        con.Close();

 

      //myfriend User_LoginID=  Session["LoginID"];

      //friendProfile ID = Session["ShowProfile"];

 

    }

 

    public string friend_User_LoginId()

    {

        con=new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "select * from Registration where RegistrarionID='" + Session["ShowProfile"] + "' ";

        da = new SqlDataAdapter(cmd);

        cmd.Connection = con;

        da.Fill(ds);      

        //cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        friendUserId = ds.Tables[0].Rows[0][1].ToString();

        con.Close();

        return friendUserId;

    }

 

    public string FriendName()

    {

        //Session["Friend_Name"];

        con=new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText = "select * from Registration where RegistrarionID='" + Session["ShowProfile"] + "' ";

        da = new SqlDataAdapter(cmd);

        cmd.Connection = con;

        da.Fill(ds);      

        //cmd.Connection = con;

        con.Open();

        cmd.ExecuteNonQuery();

        friendUserId = ds.Tables[0].Rows[0][3].ToString();

        con.Close();

        return friendUserId;

      

   

    }

 

    public void HomePage_Click(object sender, System.EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

}



Figure 8: From here  we can make friend this user .

If any registered users want to see the friend list:

MyFriendList.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyFriendList.aspx.cs" Inherits="MyFriendList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>My Friend List</title>

</head>

<body>

    <form id="form1" runat="server">

    <div><table cellpadding="0" cellspacing="0" width="80%" align="center" background="BackGround.jpg">

    <tr><td height="50px"></td></tr>

    <tr><td><marquee><asp:Label ID="lblMFriendAll" runat="server"

               Text="MY Friend" Font-Bold="true" Font-Size="20pt" ForeColor="#660099">

                </asp:Label> </marquee></td></tr>

    <tr><td height="20px"></td></tr>

    <tr><td>

    <table cellpadding="0" cellspacing="0" width="50%" align="center">

     <tr><td> <asp:DataGrid ID="GridAllRecord" runat="server"  AutoGenerateColumns="false" Width="90%"

                   DataKeyField="Friend_UserLoginId" PagerStyle-HorizontalAlign ="Center" 

                   BorderStyle="ridge" GridLines="Both" BorderWidth="2px" BorderColor ="white"

                   BackColor="white" CellPadding="3" CellSpacing="1" OnItemCommand="Grid_ItemCommand"

                   AllowSorting="true" PageSize=5 OnPageIndexChanged="GridAllRecord_PageIndexChanged"

                   AllowPaging="true">

                   <FooterStyle ForeColor="Black" BackColor="#C6C3C6"> </FooterStyle>

                   <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#A53A6A"> </HeaderStyle>

                   <FooterStyle BackColor="beige" />

                   <PagerStyle Font-Bold="true" Mode=NumericPages Font-Underline="true"/>

                   <Columns>

                   <asp:BoundColumn DataField=Friend_UserLoginId HeaderText="Friend_UserLoginId" Visible="False">

                      <ItemStyle BackColor="graytext" />

                       <HeaderStyle BackColor="graytext" />

                     </asp:BoundColumn>

                     <asp:BoundColumn DataField=ID HeaderText="ID" Visible="True">

                      <ItemStyle BackColor="graytext" />

                       <HeaderStyle BackColor="graytext" />

                     </asp:BoundColumn>                      

                                        

                    <asp:TemplateColumn HeaderText="First Name">

                      <ItemTemplate>

                        <asp:LinkButton ID="lnkName" runat="server"

                         Text='<%#DataBinder.Eval(Container.DataItem,"MyFriendName") %>'

                          CommandName="RecordShow">

                        </asp:LinkButton>

                      </ItemTemplate>

                     </asp:TemplateColumn>

                    

                     <%--<ItemTemplate>

                        <asp:LinkButton ID="lnkName" runat="server"

                         Text='<%#DataBinder.Eval(Container.DataItem,"MyFriendName") %>'

                          CommandName="RecordShow">

                        </asp:LinkButton>

                      </ItemTemplate>--%>

                  </Columns>

               </asp:DataGrid> 

         </td></tr> </table>

               </td></tr>

               <tr><td height="22px"></td></tr>              

               <tr><td>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;

                &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;

                &nbsp;&nbsp;&nbsp;               

           <asp:Button ID="btnHomePage" runat="server" Text="Home Page" Width="200px" Height="40px"

             OnClick="HomePage_Click" ForeColor="#006600"/>

           <asp:Button ID="btnMyProfile" runat="server" Text="My Profile" Width="200px" Height="40px"

              OnClick="MyProfile_Click" ForeColor="#006600" />

        </td></tr>

       </table>

      </div>

    </form>

  </body>

</html>

MyFriendList.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class MyFriendList : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        MyAllFriend();

    }

    SqlConnection con;

    SqlDataAdapter da;

    DataSet ds = new DataSet();

    SqlCommand cmd = new SqlCommand();

 

    public void MyAllFriend()

    {

        con = new SqlConnection(ConfigurationSettings.AppSettings["Connect"]);

        cmd.CommandText="select * from FriendRecord where Register_User_LoginID='"+Session["LoginID"]+"'";

        cmd.Connection=con;

        da=new SqlDataAdapter(cmd);

        da.Fill(ds);

        con.Open();

        cmd.ExecuteNonQuery();

        GridAllRecord.DataSource=ds;

        GridAllRecord.DataBind();

    }

 

    protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e)

    {

        if (e.CommandName == "RecordShow")

        {

            string Friend_Id =(e.Item.Cells[0].Text);

            Session["Friend_ID"] = Friend_Id;

            Response.Redirect("MyFriend.aspx");

        }

    }

 

    public void GridAllRecord_PageIndexChanged(object source, DataGridPageChangedEventArgs e)

    {

        GridAllRecord.CurrentPageIndex = e.NewPageIndex;

        MyAllFriend();

    }

    protected void HomePage_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

  

    protected void MyProfile_Click(object sender, EventArgs e)

    {

        Response.Redirect("MyAccount.aspx");

    }

 

}



Figure 9: The list of my friend

If user want to see the friend profile:

MyFriend.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyFriend.aspx.cs" Inherits="MyFriend" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>My Friend</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

       <table background="BackGround.jpg" cellpadding="0" cellspacing="0" width="100%">

      <tr><td height="10px">     

      </td></tr>

      <tr><td width="25%" bgcolor="black"></td>

          <td bgcolor="black">

           &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;

              &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;

              <asp:Label ID="lblFirstName" runat="server" ForeColor="#ff66ff" Font-Bold="true"

                Font-Size="20pt"> </asp:Label>

              <asp:Label ID="lblLastName" runat="server" ForeColor="#ff66ff" Font-Bold="true"

                 Font-Size="20pt"></asp:Label>                

      </td></tr>

     

      <tr><td height="15px"></td></tr>

      <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblwebPage" runat="server" Text="Web Page Name"

                           Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtWebPage" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblEMail" runat="server" Text="E-Mail" Width="170px"

                           Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtEMail" runat="server" Enabled="false"

                           ForeColor="#ff00ff"> </asp:TextBox>

                  </td></tr>

                                                    

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAboutYourSelf" runat="server"

                           Text="About YourSelf" Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAboutAyourSelf" runat="server"  ForeColor="#ff00ff"> </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblInterest" runat="server" Text="Interest" Width="170px"

                          Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtInterest" runat="server" ForeColor="#ff00ff">

                          </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouritePassTime" runat="server" Text="Favourite Pass Time"

                          Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouritePassTime" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                  </td></tr> 

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteMovie" runat="server" Text="Favourite Movie" 

                          Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteMovie" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                  </td></tr>

                 

                  <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActor" runat="server" Text="Favourite Actor"

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtFavouriteActor" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblFavouriteActress" runat="server" Text="Favourite Actress" Width="170px" Font-Bold="true" ForeColor="#333399"></asp:Label>

                        <asp:TextBox ID="txtFavouriteActress" runat="server" ForeColor="#ff00ff"></asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblBestPlaceToLive" runat="server" Text="Best Place To live"

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtBestPlace" runat="server" ForeColor="#ff00ff">

                       </asp:TextBox>

                   </td></tr>

                   

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblUnforgettableMoment" runat="server" Text="UnForgettable Moment"

                          Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtUnForgettableMoment" runat="server" TextMode="MultiLine"

                          ForeColor="#ff00ff"> </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine1" runat="server" Text="Address Line 1" Width="170px"

                          Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine1" runat="server" ForeColor="#ff00ff">

                        </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblAddressLine2" runat="server" Text="Address Line 2"

                         Width="170px" Font-Bold="true" ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtAddressLine2" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td width="25%"></td>

                       <td>

                        <asp:Label ID="lblCity" runat="server" Text="City" Width="170px" Font-Bold="true"

                         ForeColor="#333399"> </asp:Label>

                        <asp:TextBox ID="txtCity" runat="server" ForeColor="#ff00ff">

                         </asp:TextBox>

                   </td></tr>

                  

                   <tr><td height="20px"></td></tr>

                   <tr><td width="25%"></td><td>

                   <asp:Button ID="btnHomePage" runat="server" Text="Home Page" Width="250px"

                    OnClick="HomePage_Click" ForeColor="#006600"/>

                   <asp:Button ID="btnMyFriendList" runat="server" Text="My Friend" Width="200px"

                     OnClick="MyFriend_Click" ForeColor="#006600" />

                   </td></tr>

                   <tr><td height="20px"> </td></tr>

             </table>     

           </div>

      </form>

   </body>

</html>

MyFriend.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

 

public partial class MyFriend : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        MySelectedFriend();

    }

 

    SqlConnection con;

    SqlCommand cmd = new SqlCommand();

    SqlDataAdapter da;

    DataSet ds = new DataSet();

    SqlDataReader dr;

 

    public void MySelectedFriend()

    {

        con = new SqlConnection(ConfigurationManager.AppSettings["Connect"]);

        cmd.CommandText = "select * from Registration where Register_User_LoginID='" + Session["Friend_ID"] + "'";

        cmd.Connection = con;

        da = new SqlDataAdapter(cmd);

        da.Fill(ds);

        con.Open();

        cmd.ExecuteReader();

        lblFirstName.Text=ds.Tables[0].Rows[0][3].ToString();

        lblLastName.Text=ds.Tables[0].Rows[0][5].ToString();

        txtAboutAyourSelf.Text = ds.Tables[0].Rows[0][7].ToString();

        txtAddressLine1.Text = ds.Tables[0].Rows[0][14].ToString();

        txtAddressLine2.Text = ds.Tables[0].Rows[0][15].ToString();

        txtBestPlace.Text = ds.Tables[0].Rows[0][12].ToString();

        txtCity.Text = ds.Tables[0].Rows[0][16].ToString();

        txtEMail.Text = ds.Tables[0].Rows[0][2].ToString();

        txtFavouriteActor.Text = ds.Tables[0].Rows[0][10].ToString();

        txtFavouriteActress.Text = ds.Tables[0].Rows[0][11].ToString();

        txtFavouriteMovie.Text = ds.Tables[0].Rows[0][18].ToString();

        txtFavouritePassTime.Text = ds.Tables[0].Rows[0][9].ToString();

        txtInterest.Text = ds.Tables[0].Rows[0][8].ToString();

        txtUnForgettableMoment.Text = ds.Tables[0].Rows[0][13].ToString();

        txtWebPage.Text = ds.Tables[0].Rows[0][6].ToString();

        con.Close();

    }

    protected void HomePage_Click(object sender, EventArgs e)

    {

        Response.Redirect("AllRegisteredUsers.aspx");

    }

 

    protected void MyFriend_Click(object sender, System.EventArgs e)

    {

        Response.Redirect("MyFriendList.aspx");

    }

}



Figure 10: Friend profile.


Similar Articles