Sunday, September 05, 2004

ViewState in ASP.NET 2.0

Viewstate in ASP.NET 2.0

The release of ASP.NET 2.0 brings several improvements to the view state mechanism that will make it easier to use without hindering your site's performance.

These improvements include a

  • ASP.NET 2.0 changes serialization format
  • reduction in encoding size
  • the introduction of control state to separate behavioral state from content
  • intelligent integration with data-bound controls
  • Introduction of Control state

For example, if we place a DataGrid on a form and bind it to the authors table in the pubs database, the size of the view state string in 1.x is 12,648 characters. If we do the same in 2.0, the size of view state is reduced to 6,728 characters, a reduction of nearly half.


Control state:Control state is another type of hidden state reserved exclusively for controls to maintain their core behavioral functionality, whereas view state only contains state to maintain the control's contents (UI). Technically, control state is stored in the same hidden field as view state (being just another leaf node at the end of the view state hierarchy), but if you disable view state on a particular control, or on an entire page, the control state is still propagated.

more details..

http://www.msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/msdnmag/issues/04/10/viewstate/default.aspx