What do you understand by “ViewState”?
“ViewState”
is an ASP.NET technique which is used to hold pre-existing data in
the controls of the page when the page is posted back otherwise which would have been lost. The “ViewState” data is not
stored in the server rather it is transported to and from from the
server.
The data contained in the “ViewState” is stored as name
value pairs, it actually stores the ID of the control and its value
rather than the control itself in an encrypted format.
It is stored
in a hidden field called “_VIEWSTATE”. When we look at the page source it will show up something like this
Be very diligent in using the ViewState from within the code behind as it only adds to the overhead of the page to be displayed. Code to user the ViewState from within the code behind as shown below


Comments
Post a Comment