views:

51

answers:

3

I'm looking for an easy way to explain this to someone. Apologies if it has been asked before.

+1  A: 

It is a way to persist the page state between postbacks on the client. It represents a serialized string of the state of a page stored inside a hidden field and posted to the server at each request/postback (ASP.NET uses a single form and every time the user performs an action like clicking on the button this form is submitted to the server). Once the serialized state is submitted to the server it is capable of retrieving values that have been stored inside the view state.

Further reading: Understanding ASP.NET View State

Darin Dimitrov
so, to be more succinct, would you call it a "serialized string of data that preserves the page state between postbacks"?
KevinDeus
A: 

By default, dynamic web pages do not keep their state. For example, you set a value for a variable in the page load event of asp.net page. You want to increment this variable when user clicks button. This is not possible because at every page postback, the variable is created and the page load event is executed therefore, the variable is set to the initial value. Then, you need a way to keep the value of variable even if page postback occurs. Viewstate can be used to solve this problem.

Oki