O'Reilly logo

Learning ASP.NET 2.0 with AJAX by Dan Hurwitz, Jesse Liberty, Brian MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

State

State, in the case of a web page, is the current value of all the controls and variables, for the current user, in the current session. The Web is inherently a stateless environment, which means that each time a page is posted to the server and then sent back to the browser, the page is created again from scratch. Unless the state of all the controls is explicitly preserved before the page is posted, the state is lost and all the controls will be created with default values. One of the great strengths of ASP.NET is that it automatically maintains state for server controls—both HTML and ASP.NET—so you do not have to write any code to accomplish this. This section will explore how this is done and how you can make use of the ASP.NET state management capabilities.

ASP.NET manages four types of state:

Control state

Used to provide features such as paging and sorting of GridView controls. Control state cannot be modified, accessed directly, or disabled.

View state

The state of all the controls on the page. View state only lasts for that one page display, and is updated every time the page is redrawn. It can be disabled for specific controls, the page, or the entire web site.

Session state

Data specifically saved across page posts, for use by all the pages in a web application.

Application state

Data available to all the users of a web application, even across multiple sessions.

Table 7-1 compares the kinds of state management (other than Control state, which is not accessible to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required