Help of session shown email id into next page

Posted by Sandeepraturi under C# category on | Points: 40 | Views : 1767
//Database field

id= int(auot increment and primary key)


Email: <asp:TextBox ID="name" runat="server"></asp:TextBox>
password:<asp:TextBox ID="pass" runat="server" TextMode="Password"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="login"
onclick="btn_Click" />

//c# code for sessionexample.aspx

protected void btn_Click(object sender, EventArgs e)
SqlDataAdapter dap = new SqlDataAdapter("select * from login where username='"+name.Text+"' and password='"+pass.Text+"'",con);
DataSet ds = new DataSet();
Session["username"] = ds.Tables[0].Rows[0][1].ToString();

now we get the session ,create new page sessionexample2.aspx

<style type="text/css">a {text-decoration: none}</style>

<asp:Label ID="lb" runat="server" ForeColor="#6699FF" ></asp:Label> <a href="sessionexample.aspx" style="text-decoration: none; ">logout</a>

//c# code for sessionexample2.aspx

protected void Page_Load(object sender, EventArgs e)
if (IsPostBack != true)

lb.Text = Session["username"].ToString();


Comments or Responses

Login to post response