how to use session to bind the values in next page

Raj_Chennai
Posted by Raj_Chennai under ASP.NET category on | Points: 40 | Views : 1426
default.aspx
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

default.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
string s = TextBox1.Text;
Session["name"] =s ;
}

default2.aspx
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

put this content in pageload of default2.asp.cs

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["name"].ToString();

}

Comments or Responses

Login to post response