Monday, 14 January 2013 13:55

what is ViewState in asp.net

Written by 
Rate this item
(0 votes)

ASP.NET controls automatically keep their data
when page is sent to the server in response to
events (like a user clicking a button).
this persistence of data is called view state

pages maintain view state by encrypting
data within a hidden form field.watch the source
page after you’ve submitted the form,then look
for the following codes:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTEwNDY1Nzg0MQ9…0fMCR+FN5P6v5pkTQwNEl5xhBk" />

you can save any value of a variable in a ViewState-

string temp="test";
ViewState["SurveyId"]=temp;

then you can get back the value later by the following
way-

string var=ViewState["SurveyId"];

Read 2960 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.