Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Control Class
Control Properties
 ViewStateMode Property
Collapse All/Expand All Collapse All
.NET Framework Class Library
Control..::.ViewStateMode Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets or sets the view-state mode of this control.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
<ThemeableAttribute(False)> _
Public Overridable Property ViewStateMode As ViewStateMode
    Get
    Set
Visual Basic (Usage)
Dim instance As Control
Dim value As ViewStateMode

value = instance.ViewStateMode

instance.ViewStateMode = value
C#
[ThemeableAttribute(false)]
public virtual ViewStateMode ViewStateMode { get; set; }
Visual C++
[ThemeableAttribute(false)]
public:
virtual property ViewStateMode ViewStateMode {
    ViewStateMode get ();
    void set (ViewStateMode value);
}
F#
[<ThemeableAttribute(false)>]
abstract ViewStateMode : ViewStateMode with get, set
[<ThemeableAttribute(false)>]
override ViewStateMode : ViewStateMode with get, set

Property Value

Type: System.Web.UI..::.ViewStateMode
The view-state mode of this control.
ExceptionCondition
ArgumentOutOfRangeException

An attempt was made to set this property to a value that is not in the ViewStateMode enumeration.

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.

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.

The ViewStateMode property of a page or a control has an effect only if the EnableViewState property is set to true. If the EnableViewState property is set to false, view state will be turned off even if the ViewStateMode property is set to Enabled.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 4
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker