Represents an item that is saved in the StateBag class when view state information is persisted between Web requests. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
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 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 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 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.