Control.EnableViewState Property
Assembly: System.Web (in system.web.dll)
/** @property */ public boolean get_EnableViewState () /** @property */ public void set_EnableViewState (boolean value)
public function get EnableViewState () : boolean public function set EnableViewState (value : boolean)
Property Value
true if the server control maintains its view state; otherwise false. The default is true.You must enable view state for the server control to maintain its state across HTTP requests.
A server control's view state is the accumulation of all its property values. In order to preserve these values across HTTP requests, ASP.NET uses an instance of the StateBag class to store the property values. The values are then passed as a variable to a hidden field when subsequent requests are processed. For more information about view state, see View State Overview.
There are times when it is appropriate to disable view state, particularly to improve application performance. For example, if you are loading a database request into a server control, set this property to false. If you do not, processor time will be wasted loading view state into the server control that will only be overridden by the database query. If EnableViewState is false, you can use the control state to persist property information that is specific to a control and cannot be turned off like the view state property. For more information on the difference between control state and view state, see Control State vs. View State Example. For information on new state management functionality in ASP.NET 2.0, see What's New in ASP.NET State Management.
For information about how to enable or disable view state declaratively for an ASP.NET page, see @ Page.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
Control ClassControl Members
System.Web.UI Namespace
ViewState
LoadViewState
SaveViewState
IsViewStateEnabled
Other Resources
@ PageASP.NET Page Life Cycle Overview
ASP.NET State Management
ASP.NET State Management Overview
Control State vs. View State Example
What's New in ASP.NET State Management