can anyone give me what is view state with example?
srimathi parthasarathy
HTTP is a stateless protocol. So It can't hold the state of the control between the postback. Viewstate means storing the state of the server control between the page postback. We can Enable and Disable this property in the each control by 'EnableViewState' property. It stores in the hidden filed by the form of Base64 Encoded string.
Example : We can see Type,Name and Base64 Encoded string
View State is basically a client side trechnique,
it allows the state of object to be stored ion a hidden field. on the page,
its lifespan :- life of the current page (including postback)
[email protected]
Each control on a Web Forms page, including the page itself, has a ViewState property, it is a built-in struture for automatic retention of page and control state, which means you don’t need to do anything about getting back the data of controls after posting page to the server.Here, which is useful to us is the ViewState property, we can use it to save information between round trips to the server.[c#]//to save informationViewState.Add(“shape”,”circle”);//to retrieve informationstring shapes=ViewState[“shape”];Note: Unlike Hidden Field, the values in ViewState are invisible when ‘view source’, they are compressed and encoded.Regards
Sekhar Reddy.B