System.Web.UI.HiddenFieldPageStatePersister Class

Stores ASP.NET page view state on the Web client in a hidden HTML element.

See Also: HiddenFieldPageStatePersister Members


public class HiddenFieldPageStatePersister : PageStatePersister


ASP.NET pages can store System.Web.UI.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 System.Web.UI.Page class can use the System.Web.UI.HiddenFieldPageStatePersister class to do this work. System.Web.UI.HiddenFieldPageStatePersister implements the HiddenFieldPageStatePersister.Save and HiddenFieldPageStatePersister.Load methods of the System.Web.UI.PageStatePersister class so that the System.Web.UI.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 System.Web.UI.Page instance that is requested has an associated System.Web.UI.Adapters.PageAdapter class, it retrieves the System.Web.UI.PageStatePersister object from this adapter using the System.Web.UI.Adapters.PageAdapter.GetStatePersister method. Adapters can override the System.Web.UI.Adapters.PageAdapter.GetStatePersister method to return a System.Web.UI.PageStatePersister object that stores page and control state in some way that a specific client supports. For example, the System.Web.UI.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 Page.MaxPageStateFieldLength property or through the System.Web.Configuration.PagesSection.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.


Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0