viewstate property

India
February 17, 2007 2:33am CST
hey guys, tell me in detail about viewstate property and how does it work???
2 responses
@bzinger (412)
• United States
1 Mar 07
yo man - it can be used for several reasons. .net uses this object class internally to retain information on postback. a programmer can also use this to set specific object values to also retain values on postback. good luck.
25 Apr 07
I agree with bzinger!
• 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"];