Export (0) Print
Expand All

StateItem Class

Represents an item that is saved in the StateBag class when view state information is persisted between Web requests. This class cannot be inherited.

System::Object
  System.Web.UI::StateItem

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public ref class StateItem sealed

The StateItem type exposes the following members.

  NameDescription
Public propertyIsDirtyGets or sets a value indicating whether the StateItem object has been modified.
Public propertyValueGets or sets the value of the StateItem object that is stored in the StateBag object.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

View state is the accumulation of a page's or an ASP.NET server control's property values and is sent to the requesting browser in a hidden field.

You can explicitly add StateItem objects to an ASP.NET server control's StateBag object using either the Item property or the Add method. The StateBag then tracks changes to all the items that it stores. Any changes to a StateItem object are reflected in its IsDirty property. These changes are saved by a call to the SaveViewState method during the save view state phase of server control processing, just before the control is rendered to the page. For more information, see ASP.NET Web Server Controls.

The following code example uses the Value and IsDirty properties of the StateItem class to save the state of a simple custom ASP.NET server control class, StateBagSample. When the page has posted to the server, the IsDirty property checks whether the item has been modified. The state values are displayed by accessing the Value property.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft