Maintaining state

ASP.NET pages are inherently stateless—they are executed, rendered, and destroyed on every round trip to the server. You can use several techniques to maintain state, such as posting a page back to itself or storing state on the server in Session state. DataWindow .NET provides two different techniques to manage data:

The context management system is similar to ASP.NET ViewState management.

About ASP.NET ViewState management

ASP.NET automatically restores values into form fields on postback using the HTTP header. It uses a concept called ViewState to keep track of server control state values that are not posted back as part of the form, such as the text of a Label control or settings for scroll bar properties. The WebDataWindowControl uses ViewState to maintain the state of various properties, such as the LibraryList and DataWindowObject, but it does not use ViewState to maintain the data.

ViewState is a hidden form field managed by the .NET page framework. When an ASP.NET page is executed, all the values that make up the page’s ViewState are encoded into a single string and assigned to the value of the hidden form field. This value is stored on the client’s browser in the page sent to the client, and posted back to the server if the page is posted back to the server.

When the page is posted back, ASP.NET parses the encoded string and uses the individual values to repopulate property values of the page and its controls.

ViewState is available on all pages with the server-side form tag, <form runat="server">.

ViewState is enabled by default. To reduce page size, you can turn it off for a control or a page when it is not needed, such as when the control has no dynamic values or when the page does not post back to itself. Otherwise, EnableViewState should always be set to true.