protected void Page_Load(object sender, EventArgs e)
{
if(ViewState["id"] !=null)
{
Response.Write("old value "+ViewState["id"].ToString() );
}
ViewState["id"] = "Y";
Label1.Text ="current value "+ ViewState["id"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["id"] = "X";
Label1.Text = "current value " + ViewState["id"].ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
//dont do anything
}
First in page load observe the result and then click button 1 and button 2 and see the result.
//output
current value Y
old value Y current value X // Button 1 click
old value X current value Y // Button 2 click
Chaitanya
Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator