Showing posts with label ViewState. Show all posts
Showing posts with label ViewState. Show all posts

Tuesday, January 27, 2015

How to access ViewState of one page in another page in Asp.Net?

You can't access ViewState of one page from another page directly. If you want to access a particular ViewState value then you can pass the value in Context collection and then access the value in other page.

In Page 1:

Context.Items.Add("employee" ,ViewState["employee"].ToString());


In Page 2:


string employeeName = Context.Items["employee"].ToString();

Hope this helps!