Monday, June 8, 2009

What is ViewState in ASP.NET?

ViewState is used to maintain state of the page across the postback. Values are saved in encrypted form in hidden controls.
By default ViewState is enabled on ASP.NET Web Forms. If you dont want to maintain the ViewState, include the directive <%@ Page EnableViewState="false" %> at the top of an .aspx page.
Also you can switch viewstate on or off for any web control by setting EnableViewState property as true or false.

1 comment: