Home

Friday, 15 July 2016

Send Data to another Page Using Session in Asp.net c#(Using Session State Management)

Step 1) Use Previous webForm1.aspx and WebForm2.aspx for User Input and User Output.
Step 2)After that use below code on Button Click event
 protected void Button1_Click(object sender, EventArgs e)
        {
            Session["Name"] = TextBox1.Text;
            Session["Email"] = TextBox2.Text;
            Response.Redirect("~/WebForm2.aspx");
        }
Step 3) After this page Completion Go to WebForm2.aspx PageLoad Event and write below code.
 protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Name"] != null && Session["Email"] != null)
            {
                Label1.Text = Session["Name"].ToString();
                Label2.Text = Session["Email"].ToString();
            }
        }

No comments:

Post a Comment