System.Web.UI.Control.EnableViewState Property

Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

Syntax

[System.Web.UI.Themeable(false)]
[System.ComponentModel.DefaultValue(true)]
public virtual bool EnableViewState { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

View state enables a server control to maintain its state across HTTP requests. View state for a control is enabled if all of the following conditions are met:

For more information, see the Control.ViewStateMode property.

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 System.Web.UI.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 ASP.NET 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 Control.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 about how to enable or disable view state declaratively for an ASP.NET page, see @ Page.

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0