From the course: Learning ASP.NET

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Understand state management

Understand state management

From the course: Learning ASP.NET

Start my 1-month free trial

Understand state management

- Let's look closer at how Web Forms excels at state management. In Visual Studio, run the Web Forms application project, make sure to set the start page to the newsletter sign up form we added earlier. Enter an email address, and then click submit. The page just posted back to the server. Notice that after it reloaded, the email address is still populated. The asp.net page framework preserves these values across round trips to the server. It does this using a mechanism called Viewstate. Right click the page in the browser and select view page source. Notice this hidden form field on line twelve, where the name starts with two leading underscores and Viewstate in capital letters. When the HTML gets rendered, the current state of the page and value save during post back are stored here. The state information is serialized as a base sixty four encoded string in this value attribute. When the page posts back to the server, the contents of Viewstate are also sent along. One thing to keep…

Contents