BT

InfoQ Homepage News New Article on ASP.NET ViewState Intricacies

New Article on ASP.NET ViewState Intricacies

Bookmarks
ViewState may be one of the most misunderstood concepts in ASP.NET.  Though simple at first glance, the significance of ViewState is often overlooked, or completely misinterpreted when working with child controls, dynamically added controls or when developing custom controls.  Dave Reed has written an article on Truly Understanding ViewState, that describes exactly how to plan ASP.NET control initialization and creation for all of these scenarios.  Proper ViewState usage (and preventing improper usage) will keep page sizes smaller, leading to much greater performance and scalability for ASP.NET applications.  For public sites built with ASP.NET, a large ViewState can also hurt search engine rankings.

Dave begins by clarifying exactly what ViewState does and does not do:
      WHAT DOES VIEWSTATE DO? 
   1. Stores values per control by key name, like a Hashtable
   2. Tracks changes to a ViewState value's initial state
   3. Serializes and Deserializes saved data into a hidden form field on the client
   4. Automatically restores ViewState data on postbacks

Even more important than understanding what it does, is understanding what it does NOT do:

   WHAT DOESN'T VIEWSTATE DO?
   1. Automatically retain state of class variables (private, protected, or public)
   2. Remember any state information across page loads (only postbacks) (that is unless you customize how the data is persisted)
   3. Remove the need to repopulate data on every request
   4. ViewState is not responsible for the population of values that are posted such as by TextBox controls (although it does play an important role)
   5. Make you coffee

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.