View state is the method that the ASP.NET page frameworkuses to preserve page and control values between round trips. When the HTMLmarkup for the page is rendered, the current state of the page and values thatmust be retained during postback are serialized into base64-encoded strings.View state is the method that the ASP.NET page framework uses to preserve page and control values between round trips. When the HTML markup for the page is rendered, the current state of the page and values that must be retained during postback are serialized into base64-encoded strings. This information is then put into the view state hidden field or fields.
This information is then put into the view state hidden field or fields. Thenext time the page is posted back, ASP.NET follows these steps:
ASP.NET re-creates the page and control objects based on itsdefaults (as defined in the .aspx file). Thus, the page has the same state thatit had when it was first requested.
Next, ASP.NET deserializes the view state information andupdates all the controls. This returns the page to the state it was in beforeit was sent to the client the last time.
Finally, ASP.NET adjusts the page according to the postedback form data
Now your event-handling code can get involved. ASP.NETtriggers the appropriate events, and your code can react to change the page, moveto a new page, or perform a completely different operation.
Using view state is a great solution because serverresources can be freed after each request, thereby allowing for scalability tosupport hundreds or thousands of requests without bogging the server down.
Drawback of ViewState
Because view state is stored in the page, it results in alarger total page size. This affects the client doubly, because the client notonly needs to receive a larger page, but the client also needs to send thehidden view state data back to the server with the next postback. Thus, ittakes longer both to receive and post the page. For simple pages, this overheadis minimal, but if you configure complex, data-heavy controls such as theGridView or ListView, the view state information can grow to a size where itstarts to exert a toll. In these cases, you can disable view state for acontrol by setting its EnableViewState property to false. However, in this caseyou need to reinitialize the control with each postback.