ViewStateMode vs EnableViewState
EDIT
ViewStateMode
- Enabled - Turns the ViewState On for this control
- Disabled - Turns the ViewState Off for this control
- Inherit - Inherits from the value of the parent control
EnableViewState
- Overrides ViewStateMode, must be true for ViewStateMode to have meaning.
See: Minimizing viewstate- confused by `EnableViewState` and `ViewStateMode` in asp.net 4.0
ORIGINAL
Understanding ASP.NET View State
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. Control.EnableViewState Property
You can use the ViewStateMode property to enable view state for an individual control even if view state is disabled for the page. For more information about view state and control state, see the EnableViewState property. Control.ViewStateMode Property
The combination allows you to turn off the ViewState for a page as a whole, but enable it for a specific control contained inside.
To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.
The default value of the ViewStateMode property for a page is Enabled. The default value of the ViewStateMode property for a Web server control in a page is Inherit. As a result, if you do not set this property at either the page or the control level, the value of the EnableViewState property determines view-state behavior.
From Control.ViewStateMode Property
Until ASP.NET version 3.5, the page level viewstate control property (EnableViewState) was treated as highest priority, meaning whether the control level property is true or false it doesn't change the behavior, it sees and uses the page level property. But, in ASP.NET version 4 and onward, the new property (ViewStateMode) is used, which has priority over the page level setting. This allows for more robust conditional settings.
Disabled - will disable the viewstate for that page or control(i.e. if the page level property is disabled and control level property is enabled, view state will work for the control).
Enabled - will enable the viewstate for that page or control(i.e. if the page level property is enabled and control level property is disabled, view state will not work for the control).
Inherit - will inherit the page viewstate property and apply it to the control viewstate property.