How to pass the data from one page to another page using session?

aswinialuri-19361
Posted by aswinialuri-19361 under ASP.NET category on | Points: 40 | Views : 1351
code in webform1.aspx page:

<table><tr><td>Hello Session:</td><td><asp:TextBox ID="txt_session" runat="server" 
ontextchanged="txt_session_TextChanged"></asp:TextBox></td></tr>
<tr><td><asp:Button ID="btn_session" runat="server" Text="Session"
onclick="btn_session_Click" /></td></tr></table>


code in webform1.aspx.cs page:

protected void btn_session_Click(object sender, EventArgs e)
{
Session["demo"] = txt_session.Text;
Response.Redirect("WebForm3.aspx");
}

code in web form2.aspx page:
drag a single label
code in web form2.aspx.cs page:

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

}

Comments or Responses

Login to post response