Thursday 28 March 2013

Access Viewstate Value On Different aspx Page

Kailash ChandelViewstate is used for state management in on same page. We can also access the Viewstate on other aspx page. For this we need to use server.transfer() method instead of response.redirect() method to redirect to the other page.

Let us have an aspx page named passviewstate.aspx . We will store two viewstates here as follow:

view state

And use server.transfer to redirect to another page named readviewstate.aspx .  We need to place a fuction of statebag class.


Now we will read these viewstate values on the page  readviewstate.aspx . For this we will create a function to read the the previous page's viewstate.

After creating the above function we will write code to show the viewstate values.

And we are done. Now we the values of two viewstate variables Name and Organisation in the labels lblMessage and lablOrganisation.

No comments:

Post a Comment

How to get code from a published ASP.Net build where we don't have source code?

If you have ever lost or misplaced your source code for an ASP.Net web application, you might wonder if there is a way to recover it from th...