Web Forms Question:
Download Job Interview Questions and Answers PDF
How to use Sessions in web forms?
Answer:
private void Button1_Click(object sender, System.EventArgs e)
{
//Drag TextBox1 and TextBox2 onto a web form
Session["name"]=TextBox1.Text;
Session["email"]=TextBox2.Text;
Server.Transfer("anotherwebform.aspx");
}
Destination web form
private void Page_Load(object sender, System.EventArgs e)
{
Label1.Text=Session["name"].ToString();
Label2.Text=Session["email"].ToString();
Session.Remove("name");
Session.Remove("email");
}
{
//Drag TextBox1 and TextBox2 onto a web form
Session["name"]=TextBox1.Text;
Session["email"]=TextBox2.Text;
Server.Transfer("anotherwebform.aspx");
}
Destination web form
private void Page_Load(object sender, System.EventArgs e)
{
Label1.Text=Session["name"].ToString();
Label2.Text=Session["email"].ToString();
Session.Remove("name");
Session.Remove("email");
}
Download Microsoft Web Forms Interview Questions And Answers
PDF
Previous Question | Next Question |
How to use QueryString in web forms? | How to use Context? |