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:
Used to provide features such as paging and sorting of
GridView controls. Control state cannot be
modified, accessed directly, or disabled.
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.
Data specifically saved across page posts, for use by all the pages in a web application.
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 ...