Stores ASP.NET page view state on the Web client in a hidden HTML element.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|ControlState||Gets or sets an object that represents the data that controls contained by the current Page object use to persist across HTTP requests to the Web server. (Inherited from PageStatePersister.)|
|Page||Gets or sets the Page object that the view state persistence mechanism is created for. (Inherited from PageStatePersister.)|
|StateFormatter||Gets an IStateFormatter object that is used to serialize and deserialize the state information contained in the ViewState and ControlState properties during calls to the Save and Load methods. (Inherited from PageStatePersister.)|
|ViewState||Gets or sets an object that represents the data that controls contained by the current Page object use to persist across HTTP requests to the Web server. (Inherited from PageStatePersister.)|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Load||Deserializes and loads persisted state information from an HttpRequest object when a Page object initializes its control hierarchy. (Overrides PageStatePersister::Load().)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|Save||Serializes any object state contained in the ViewState or ControlState property and writes the state to the response stream. (Overrides PageStatePersister::Save().)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
ASP.NET pages can store Page state between the inherently stateless HTTP request and response required to process and serve any Web page. This state is called "view state". The default mechanism used to store view state for a page and its controls is in one or more <hidden> HTML fields included in the page that is served to a client from a Web server. The Page class can use the class to do this work. implements the Save and Load methods of the PageStatePersister class so that the Page can store state in a <hidden> HTML element named "__VIEWSTATE" on a Web client. When the client requests the same page from the Web server (a postback), the <hidden> element is parsed and converted to state information by ASP.NET.
If the Page instance that is requested has an associated PageAdapter class, it retrieves the PageStatePersister object from this adapter using the GetStatePersister method. Adapters can override the GetStatePersister method to return a PageStatePersister object that stores page and control state in some way that a specific client supports. For example, the SessionPageStatePersister class stores page and controls' state on the Web server, instead of the client, to decrease the amount of information that must be sent and stored on a client that has potentially limited memory and bandwidth.
The maximum size of the "_VIEWSTATE" <hidden> HTML element can be set through the MaxPageStateFieldLength property or through the MaxPageStateFieldLength configuration setting. When this value is set and the length of the "_VIEWSTATE" element would exceed the maximum length, the content is divided into multiple "_VIEWSTATE" elements.
When the example page is viewed, any view state is stored by the class in a <hidden> HTML element named "__VIEWSTATE".
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <BODY> <form name="_ctl0" method="post" action="sample.aspx" id="_ctl0"> <input type="hidden" name="__VIEWSTATE" value="MgAwADkANgAwADkAOQA3ADgAMQD/AQ8QBQoxMTU2NDc1NjE0EGRkFgICAQ9kFgICAw8PZBAVDQVhc2RhcwhCdWNoYW5hbghDYWxsYWhhbgdEYXZvbGlvCURvZHN3b3J0aAZGdWxsZXIES2luZwhLcmF3YXJpawlMZXZlcmxpbmcETWFyeQdQZWFjb2NrBlN1eWFtYQx0ZXN0IHJlZnJlc2gVDQVhc2RhcwhCdWNoYW5hbghDYWxsYWhhbgdEYXZvbGlvCURvZHN3b3J0aAZGdWxsZXIES2luZwhLcmF3YXJpawlMZXZlcmxpbmcETWFyeQdQZWFjb2NrBlN1eWFtYQx0ZXN0IHJlZnJlc2gUKgMNZ2dnZ2dnZ2dnZ2dnZ2RkZPdhi6U7jBPqVZbj0W8AYFSJ6oiq" /> <select size="4" name="ListBox1" id="ListBox1"> <option value="Buchanan">Buchanan</option> <option value="Callahan">Callahan</option> <option value="Davolio">Davolio</option> <option value="Dodsworth">Dodsworth</option> <option value="Fuller">Fuller</option> <option value="King">King</option> <option value="Leverling">Leverling</option> <option value="Suyama">Suyama</option> </select> </form> </BODY> </HTML>
Windows Phone 8.1, Windows Phone 8, 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.