ViewState persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.
SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes.
protected void btnSubmit_Click(object sender, EventArgs e)
{
ViewState["DataScorceName"] = datasource;
ViewState["ClientName"] = txtCustomer.Text;
}
//Retrieve viewstate information
txtCname.Text = ViewState["ClientName"]
Store information in Session State:
Session["EmpName"] = txtUser.Text;
//Retrieve session value in 2nd page
lblEmp.Text = Session["UserName"].ToString();
|
No comments:
Post a Comment