viewstate property
By todwalrohit
@todwalrohit (116)
India
February 17, 2007 2:33am CST
hey guys,
tell me in detail about viewstate property and how does it work???
2 responses
@vikassah (2)
• United States
2 Mar 07
ViewState is one mechanism in ASP .NET by which controls are able to retain their state between postbacks (requests for the same page).
It is a "Page" level property and is maintained only for access to the same page multiple times and not across different page visits.
The viewstate of a page is saved in a hidden form field __VIEWSTATE. It is passed as a base64 encoded string.
Each control on a page as a property "ViewState" which it is responsible for populating, in oder to persist its state.
ViewState can be used by developer to persist page level information:
ViewState["Item"] = "rock"
You can get it back using:
string text = (string) ViewState["Item"];