Create Register form Using Store Procedure in asp.net with C#

0 comments

 



                                                         Register Form to Insert Data


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="procedure_registration.aspx.cs" Inherits="procedure_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></title>
</head>
<body bgcolor="#3399CC">
    <form id="form1" runat="server">
    <div>
            <center> <table border="1" bordercolor="white">
                         <tr>
                                <td>
                                    <h1 class="stylee">REGISTER FORM</h1>
                                </td>
                         </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label1" ForeColor="White" runat="server" Text="enter your name"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                            </td><td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="please enter your name" ForeColor="Blue"
                                ControlToValidate="TextBox1">
                            </asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label2" ForeColor="White" runat="server" Text="enter your current address"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
                            </td>
                            <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="please enter current address" ForeColor="Blue"
                                ControlToValidate="TextBox2" >
                            </asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label3" ForeColor="White" runat="server" Text="enter your home address"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine"></asp:TextBox>
                            </td>
                            <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="please enter home address" ForeColor="Blue"
                                ControlToValidate="TextBox2" >
                            </asp:RequiredFieldValidator></td>
                        </tr>
                       
                        <tr>
                            <td>
                            <asp:Label ID="Label4" ForeColor="White" runat="server" Text="select state"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
                                    DataTextField="statename" DataValueField="statename"
                                    onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                                </asp:DropDownList>
                               
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator9" ForeColor="Blue" ControlToValidate="DropDownList1" runat="server" ErrorMessage="Please select state"></asp:RequiredFieldValidator>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label5" ForeColor="White" runat="server" Text="city"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
                                    DataTextField="city" DataValueField="city"
                                    >
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator10" ForeColor="Blue" ControlToValidate="DropDownList2" runat="server" ErrorMessage="Please select city"></asp:RequiredFieldValidator>
                            </td>
                       
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label6" ForeColor="White" runat="server" Text="enter your email"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ForeColor="Blue" ErrorMessage="invalid email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="TextBox6">
                                </asp:RegularExpressionValidator><br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="TextBox6" runat="server" ErrorMessage="Please enter email"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label7" ForeColor="White" runat="server" Text="your company url"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
                            </td>
                            <td>
                            <asp:RegularExpressionValidator  
                                ID="RegularExpressionValidator2" runat="server" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"  ForeColor="Blue" ControlToValidate="TextBox7"  ErrorMessage="Input valid Internet URL!">
                                 </asp:RegularExpressionValidator> <br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator11" ControlToValidate="TextBox7" runat="server" ErrorMessage="please enter com_uri"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label14" ForeColor="White" runat="server" Text="enter your photo"></asp:Label>
                            </td>
                            <td>
                                <asp:FileUpload ID="FileUpload1" runat="server" />
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="enter photo" ForeColor="Blue" ControlToValidate="FileUpload1"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                      
                        <tr>
                            <td>
                                <asp:Label ID="Label10" ForeColor="White" runat="server" Text="enter your cellno"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox10" runat="server"
                                     ></asp:TextBox>
                            </td>
                            <td>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ForeColor="Blue"
                                ErrorMessage="add proper data" ValidationExpression="^[0-9]{10}" ControlToValidate="TextBox10"
                                ></asp:RegularExpressionValidator><br />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="TextBox10" runat="server" ErrorMessage="please enter cell"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                       <tr>
                            <td>
                                <asp:Label ID="Label8"  runat="server" ForeColor="White" Text="Gender"></asp:Label>
                            </td>
                            <td>
                                <asp:RadioButton ID="RadioButton1" ValidationGroup="ab" Checked="true" Text="male" ForeColor="White" GroupName="m" runat="server" />
                                <asp:RadioButton ID="RadioButton2" runat="server"  ForeColor="White" Text="female" GroupName="m" />
                            </td>
                            <td>
                                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="plese enetr gender" ValidationGroup="ab" ControlToValidate="RadioButton1"></asp:RequiredFieldValidator>--%>
                            </td>
                       </tr>
                       <tr>
                        <td>
                            <asp:Label ID="Label9" runat="server" Text="Hobby" ForeColor="White"></asp:Label>
                        </td>
                        <td>
                            <asp:CheckBoxList ID="CheckBoxList1" runat="server">
                            <asp:ListItem Text="reading"></asp:ListItem>
                            <asp:ListItem Text="writing"></asp:ListItem>
                            </asp:CheckBoxList>
                        </td>
                            <td>
                                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="CheckBoxList1" runat="server" ErrorMessage="please enter hobby"></asp:RequiredFieldValidator>--%>
                            </td>
                       </tr>
                       <tr>
                            <td>
                                <asp:Label ID="Label11" runat="server" Text="what is your rasi"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ErrorMessage="please answer the question" ControlToValidate="TextBox4"></asp:RequiredFieldValidator>
                            </td>
                       </tr>
                       <tr>
                            <td>
                                <asp:Label ID="Label15" runat="server" Text="what is your birth month"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="please answer the question" ControlToValidate="TextBox5"></asp:RequiredFieldValidator>
                            </td>
                       </tr>
                        <tr>
                       
                            <td>
                                <asp:Label ID="Label12" ForeColor="White" runat="server" Text="enter LoginID"></asp:Label>
                            </td>
                            
                            <td>
                                <asp:TextBox ID="TextBox12" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="please enter LoginId" ForeColor="Blue"
                                ControlToValidate="TextBox12" >
                            </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label13" ForeColor="White" runat="server" Text="enter Password"></asp:Label>
                            </td>
                            
                            <td>
                                <asp:TextBox ID="TextBox13" runat="server" TextMode="Password"></asp:TextBox>
                            </td>
                            <td>
                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="please enter Password" ForeColor="Blue"
                                ControlToValidate="TextBox12" >
                            </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" /></td>
                        </tr>
                    </table>
                </center>
    </div>
    </form>
</body>
</html>

ASPX.CS FILE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Text;

public partial class procedure_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind_ddlstate();
        }

    }
    private string encryp(string password)
    {
        string msg = string.Empty;
        byte[] encode = new byte[password.Length];
        encode = Encoding.UTF8.GetBytes(password);
        msg = Convert.ToBase64String(encode);
        return msg;
    }
    private string decrypt(string encrypt)
    {
        string decryp = string.Empty;
        UTF8Encoding encodedpass = new UTF8Encoding();
        Decoder decode = encodedpass.GetDecoder();
        byte[] todecodedbyte = Convert.FromBase64String(encrypt);
        int charcount = decode.GetCharCount(todecodedbyte, 0, todecodedbyte.Length);
        char[] dechodedchar = new char[charcount];
        decode.GetChars(todecodedbyte, 0, todecodedbyte.Length, dechodedchar, 0);
        decryp = new string(dechodedchar);
        return decryp;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string pass = encryp(TextBox13.Text);
        string ans1= TextBox4.Text;
        string ans2 = TextBox5.Text;
        string name1 =TextBox1.Text;
        string c_add = TextBox2.Text;
        string h_add=TextBox3.Text;
        string state = DropDownList1.SelectedValue;
        string city=DropDownList2.SelectedValue;
        string email=TextBox6.Text;
        string url=TextBox7.Text;
         FileUpload1.SaveAs(Server.MapPath("~/image" + FileUpload1.FileName));
        string photo = "~/image" + FileUpload1.FileName;
        string cell=TextBox10.Text;
        string gender=null;
         if (RadioButton1.Checked)
        {
           gender = RadioButton1.Text;
        }
        else
        {
            gender = RadioButton2.Text;
        }
         string hobby = string.Empty;
         foreach (ListItem item in this.CheckBoxList1.Items)
         {
             if (item.Selected)
             {
                hobby += item + ",";
             }
         }
       string userid=TextBox12.Text;
        //string pass=TextBox13.Text;
        emp_procedure p1 = new emp_procedure();
        //try
        //{
            if (p1.insert1(name1,c_add,h_add,state,city,email,url,photo,cell,gender,hobby,ans1,ans2,userid,pass) > 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "ke", "<script>alert('login successfull ');</script>");
                Response.Redirect("~/procedure_login.aspx");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "ke", "<script>alert('sorry !!!!! check your data ');</script>");
            }
        //}
       // catch
        //{
            ClientScript.RegisterClientScriptBlock(this.GetType(), "ke", "<script>alert(not enter try);</script>");
        //}
    }
    public void Bind_ddlstate()
    {

        string con = @"Data Source=SQLDB;Initial Catalog=Demo;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);
        conn.Open();
        string q = "select * from pi_statedemo";
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(q, conn);

        da.Fill(ds);

        DropDownList1.DataSource = ds;
        DropDownList1.DataBind();
        DropDownList1.Items.Insert(0, new ListItem("--select--"));
        // DropDownList2.Items.Insert(0, new ListItem("--select--"));
        //if (DropDownList1.SelectedIndex == -1)
        //{
        //    DropDownList2.SelectedIndex = -1;
        //}
        conn.Close();


    }
    public void Bind_ddlCity()
    {
        DropDownList2.Items.Clear();
        string con = @"Data Source=SQLDB;Initial Catalog=Demo;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);
        conn.Open();
        string q = "select city from pi_citydemo where id ='" + DropDownList1.SelectedIndex + "'";
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(q, conn);
        da.Fill(ds);
        DropDownList2.DataSource = ds;
        DropDownList2.DataBind();
        conn.Close();


    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Bind_ddlCity();
    }
}

                                              Login Form To Login Person

                               LOGIN.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="procedure_login.aspx.cs" Inherits="procedure_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></title>
</head>
<body bgcolor="#3399CC">
    <form id="form1" runat="server">
    <div>
    <table border="1" bordercolor="white">
    <tr>
        <td>
          <center>  <h1 class="stylee">LOGIN</h1></center>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label1" runat="server" Text="Enter UserId" ForeColor="White"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </td>
        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="please enter username" ForeColor="Blue"
                                ControlToValidate="TextBox1">
                            </asp:RequiredFieldValidator></td>
    </tr>
     <tr>
        <td>
            <asp:Label ID="Label2" runat="server" Text="Enter PassWord" ForeColor="White"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
        </td>
        <td>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="please enter Password" ForeColor="Blue"
                                ControlToValidate="TextBox1">
                            </asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td></td>
        <td>
            <asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" /></td>
          

    </tr>
</table>
<a href="procedure_registration.aspx">Registration</a><br />
<a href="forgetpass.aspx">forgetpass</a>
<br />
<br />
<br />
      
    </div>
    </form>
</body>
</html>

                LOGIN.ASPX.CS

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;

public partial class procedure_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private string encryp(string password)
    {
        string msg = string.Empty;
        byte[] encode = new byte[password.Length];
        encode = Encoding.UTF8.GetBytes(password);
        msg = Convert.ToBase64String(encode);
        return msg;
    }
    private string decrypt(string encrypt)
    {
        string decryp = string.Empty;
        UTF8Encoding encodedpass = new UTF8Encoding();
        Decoder decode = encodedpass.GetDecoder();
        byte[] todecodedbyte = Convert.FromBase64String(encrypt);
        int charcount = decode.GetCharCount(todecodedbyte, 0, todecodedbyte.Length);
        char[] dechodedchar = new char[charcount];
        decode.GetChars(todecodedbyte, 0, todecodedbyte.Length, dechodedchar, 0);
        decryp = new string(dechodedchar);
        return decryp;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string userid = TextBox1.Text;
        string pass =encryp( TextBox2.Text);
        string con = @"Data Source=SQLDB;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);

        conn.Open();
        SqlCommand cmd = new SqlCommand("dbo.pi_login", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@userid", userid);
        cmd.Parameters.AddWithValue("@pass", pass);
        SqlParameter id = cmd.Parameters.Add("@r_id", SqlDbType.Int);
        id.Direction = ParameterDirection.ReturnValue;
        cmd.ExecuteNonQuery();


        int i = Convert.ToInt32(id.Value);

        if (i > 0)
        {
          
            Session["s"] = i;
            Response.Redirect("~/showprocedure.aspx");
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "ke", "<script>alert('Sorry !!!! try agin');</script>");
        }
        conn.Close();


    }
}

                                                    Show Full Information 

SHOWINFO.ASPX

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

<!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></title>
</head>
<body bgcolor="black">
    <form id="form1" runat="server">
    <div>
       
<center>
<table border="1" bordercolor="white" width="2">
            <tr>
                <td rowspan="4">
                     <asp:Image ID="Image2" ForeColor="White" runat="server" Height="90px" Width="80px" />
                </td>
                <td>
                    <asp:Label ID="Label18" ForeColor="White" runat="server" Text="name"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label19" runat="server" ForeColor="White" Text="c_add"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label20" runat="server" Text="h_add" ForeColor="White" ></asp:Label>
                </td>
               
             
            </tr>
            <tr>
               
                <td>
                    <asp:Label ID="Label9" runat="server" ForeColor="White" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label10" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label11" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
               
            </tr>
            <tr>
                  <td>
                    <asp:Label ID="Label21" runat="server" ForeColor="White" Text="state"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label22" ForeColor="White" runat="server" Text="city"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label23" ForeColor="White" runat="server" Text="email"></asp:Label>
                </td>
                
            </tr>
            <tr>
            <td>
                    <asp:Label ID="Label12" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                     <asp:Label ID="Label13" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                 <asp:Label ID="Label14" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
               
            </tr>
            <tr>
            <td>
                    <asp:Label ID="Label24" ForeColor="White" runat="server" Text="url"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label25" ForeColor="White" runat="server" Text="cell"></asp:Label>
                </td>
                <td>
                      <asp:Label ID="Label8" ForeColor="White" runat="server" Text="gender"></asp:Label> 
                </td>
                <td>
                <asp:Label ID="Label26" ForeColor="White" runat="server" Text="Hobby"></asp:Label>
                </td>
            </tr>
            <tr>
                <td> <asp:Label ID="Label15" ForeColor="White" runat="server" Text="Label"></asp:Label></td>
                <td>
                    <asp:Label ID="Label16" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td> <asp:Label ForeColor="White" ID="Label17" runat="server" Text="Label"></asp:Label></td>
                <td> <asp:Label ForeColor="White" ID="Label27" runat="server" Text="Label"></asp:Label></td>
            </tr>
           
        </table></center>
       
        <asp:Button ID="Button1" runat="server" Text="Logout" onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>

SHOWINFO.ASPX.CS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;

public partial class showprocedure : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        grid();
    }
    private string decrypt(string encrypt)
    {
        string decryp = string.Empty;
        UTF8Encoding encodedpass = new UTF8Encoding();
        Decoder decode = encodedpass.GetDecoder();
        byte[] todecodedbyte = Convert.FromBase64String(encrypt);
        int charcount = decode.GetCharCount(todecodedbyte, 0, todecodedbyte.Length);
        char[] dechodedchar = new char[charcount];
        decode.GetChars(todecodedbyte, 0, todecodedbyte.Length, dechodedchar, 0);
        decryp = new string(dechodedchar);
        return decryp;
    }
    public void grid()
    {
        string con = @"Data Source=SQLDB;Initial Catalog=Demo;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);
        string q = "select * from pi_registration1 where r_id='"+Session["s"].ToString()+ "' ";

      //  SqlDataAdapter da = new SqlDataAdapter();
        //DataTable ds = new DataTable();
       SqlCommand cmd1 = new SqlCommand(q, conn);
        conn.Open();
        //da.SelectCommand = cmd1;

        //cmd1.ExecuteNonQuery();
        //da.Fill(ds);
        //GridView1.DataSource = ds;
        //GridView1.DataBind();

        SqlDataReader dr = cmd1.ExecuteReader();
        while (dr.Read())
        {
            Image2.ImageUrl = dr[8].ToString();
            Label9.Text = dr[1].ToString();
            Label10.Text = dr[2].ToString();
            Label11.Text = dr[3].ToString();
            Label12.Text = dr[4].ToString();
            Label13.Text = dr[5].ToString();
            Label14.Text = dr[6].ToString();
            Label15.Text = dr[7].ToString();
            Label16.Text = dr[9].ToString();
            Label17.Text = dr[10].ToString();
            Label27.Text = dr[13].ToString();
           
        }
       
        conn.Close();
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("procedure_login.aspx");
    }
}

 

                                                Forget Password

      FORGET PASSWORD.ASPX                  

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

<!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></title>
</head>
<body bgcolor="black">
    <form id="form1" runat="server">
    <div style="width: 312px">
        <table border="1" bordercolor="white">
        <tr>
          <td>
        <asp:Label ID="Label1" runat="server" ForeColor="White" Text="what is your rasi"></asp:Label><br />
        </td>
        <td>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="Label2" runat="server" ForeColor="White" Text="what is your birth month"></asp:Label><br />
        </td>
        <td>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
        </td>
        </tr>
        <tr>
         <td>
        <asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" />
        </td>
        </tr>
        </table>
    </div>
    </form>
</body>
</html>

FORGETPASSWORD.ASPX.CS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;

public partial class forgetpass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ans1 = TextBox1.Text;
        string ans2 = TextBox2.Text;
        string con = @"Data Source=SQLDB;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);

        conn.Open();
        SqlCommand cmd = new SqlCommand("dbo.StoredProcedure5", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@ans1", ans1);
        cmd.Parameters.AddWithValue("@ans2", ans2);
        SqlParameter id = cmd.Parameters.Add("@r_id", SqlDbType.Int);
        id.Direction = ParameterDirection.ReturnValue;
        cmd.ExecuteNonQuery();


        int i = Convert.ToInt32(id.Value);

        if (i > 0)
        {

            Session["s"] = i;
            Response.Redirect("~/showpass.aspx");
        }
        else
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "ke", "<script>alert('Sorry !!!! try agin');</script>");
        }
        conn.Close();
    }
}

 

                       Show Your Password and Information 

SHOWPASS.ASPX

<form id="form1" runat="server">
    <div>
    <center><table border="1" bordercolor="white" width="2">
            <tr>
                <td rowspan="4">
                     <asp:Image ID="Image2" ForeColor="White" runat="server" Height="90px" Width="80px" />
                </td>
                <td>
                    <asp:Label ID="Label18" ForeColor="White" runat="server" Text="name"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label19" runat="server" ForeColor="White" Text="c_add"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label20" runat="server" Text="h_add" ForeColor="White" ></asp:Label>
                </td>
               
             
            </tr>
            <tr>
               
                <td>
                    <asp:Label ID="Label9" runat="server" ForeColor="White" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label10" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label11" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
               
            </tr>
            <tr>
                  <td>
                    <asp:Label ID="Label21" runat="server" ForeColor="White" Text="state"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label22" ForeColor="White" runat="server" Text="city"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label23" ForeColor="White" runat="server" Text="email"></asp:Label>
                </td>
                
            </tr>
            <tr>
            <td>
                    <asp:Label ID="Label12" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                     <asp:Label ID="Label13" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                 <asp:Label ID="Label14" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
               
            </tr>
            <tr>
            <td>
                    <asp:Label ID="Label24" ForeColor="White" runat="server" Text="url"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="Label25" ForeColor="White" runat="server" Text="cell"></asp:Label>
                </td>
                <td>
                      <asp:Label ID="Label8" ForeColor="White" runat="server" Text="gender"></asp:Label> 
                </td>
                <td>
                <asp:Label ID="Label26" ForeColor="White" runat="server" Text="Hobby"></asp:Label>
                </td>
            </tr>
            <tr>
                <td> <asp:Label ID="Label15" ForeColor="White" runat="server" Text="Label"></asp:Label></td>
                <td>
                    <asp:Label ID="Label16" ForeColor="White" runat="server" Text="Label"></asp:Label>
                </td>
                <td> <asp:Label ForeColor="White" ID="Label17" runat="server" Text="Label"></asp:Label></td>
                <td> <asp:Label ForeColor="White" ID="Label27" runat="server" Text="Label"></asp:Label></td>
            </tr>
           
        </table></center>
        <table border="1" bordercolor="white">
        <tr>
        <td>
        <asp:Label ID="Label1" ForeColor="White" runat="server" Text="username is"></asp:Label>
        </td>
        <td>
        <asp:Label ID="user" ForeColor="White" runat="server" Text="Label"></asp:Label>
        </td>
        </tr>
        <tr>
        <td>
        <asp:Label ID="Label3" runat="server" ForeColor="White" Text="Password is"></asp:Label>
        </td>
        <td>
        <asp:Label ID="ps" runat="server" ForeColor="White" Text="Label"></asp:Label>
        </td>
        </tr>
        </table>
        <asp:Button ID="Button1" runat="server" Text="Logout" onclick="Button1_Click" />
    </div>
    </form>

SHOWPASS.ASPX.CS


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;

public partial class showpass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        grid();
    }
    private string decrypt(string encrypt)
    {
        string decryp = string.Empty;
        UTF8Encoding encodedpass = new UTF8Encoding();
        Decoder decode = encodedpass.GetDecoder();
        byte[] todecodedbyte = Convert.FromBase64String(encrypt);
        int charcount = decode.GetCharCount(todecodedbyte, 0, todecodedbyte.Length);
        char[] dechodedchar = new char[charcount];
        decode.GetChars(todecodedbyte, 0, todecodedbyte.Length, dechodedchar, 0);
        decryp = new string(dechodedchar);
        return decryp;
    }
    public void grid()
    {
        string con = @"Data Source=SQLDB;Initial Catalog=Demo;User ID=Demoh;Password=Demo1@";
        SqlConnection conn = new SqlConnection(con);
        string q = "select * from pi_registration1 where r_id='" + Session["s"].ToString() + "' ";

        //  SqlDataAdapter da = new SqlDataAdapter();
        //DataTable ds = new DataTable();
        SqlCommand cmd1 = new SqlCommand(q, conn);
        conn.Open();
        //da.SelectCommand = cmd1;

        //cmd1.ExecuteNonQuery();
        //da.Fill(ds);
        //GridView1.DataSource = ds;
        //GridView1.DataBind();

        SqlDataReader dr = cmd1.ExecuteReader();
        while (dr.Read())
        {
            Image2.ImageUrl = dr[8].ToString();
            Label9.Text = dr[1].ToString();
            Label10.Text = dr[2].ToString();
            Label11.Text = dr[3].ToString();
            Label12.Text = dr[4].ToString();
            Label13.Text = dr[5].ToString();
            Label14.Text = dr[6].ToString();
            Label15.Text = dr[7].ToString();
            Label16.Text = dr[9].ToString();
            Label17.Text = dr[10].ToString();
            Label27.Text = dr[11].ToString();
            user.Text = dr[14].ToString();
            ps.Text = decrypt(dr[15].ToString());
            Response.Write("<script> alert( 'your password is " + ps.Text + "'); </script>");
        }

        conn.Close();

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("procedure_login.aspx");
    }
}


Read More »