1 / 9

ASP.NET Page State

ASP.NET Page State. Wallace B. McClure Scalable Development, Inc. ASP.NET Podcast http://www.aspnetpodcast.com/. State. ViewState ViewState is the mechanism in ASP.NET to keep page state between postbacks. Used to cause page level events such as button clicks.

menefer
Download Presentation

ASP.NET Page State

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET Page State Wallace B. McClure Scalable Development, Inc. ASP.NET Podcast http://www.aspnetpodcast.com/

  2. State • ViewState • ViewState is the mechanism in ASP.NET to keep page state between postbacks. • Used to cause page level events such as button clicks. • Hidden form element – default. • ControlState • Control State data specific to a control • Separate from ViewState.

  3. Problem • ViewState size can be rather large. If it is sent between the server and client, it can significant take time to transfer the data. • 300K-500K-1000K is not uncommon. • Turning off ViewState can break controls with special state needs, thus ControlState is separate from ViewState.

  4. Solution • Store ViewState/ControlState someplace besides a hidden formfield element. • Alternative locations: • Webserver – How do you handle a webfarm? • Database • Problems: • Cleanup. • Back button. • AJAX.

  5. Load/Save Data • Inherit from the PageStatePersister. • Override Load()/Save()

  6. State() • Obtain ViewState/ControlState. • Save to a Pair object. • Serialize the Pair to a string. • Save the string. • Register the unique identifier. • PK in a database. • Filename in the file system.

  7. Load() • Read the unique identifier. • Cleanup old values. • Obtain the serialized pair object. • Deserialize the pair. • Set the ViewState/ControlState properties.

  8. Final Thoughts • Deleting the previous value destroys the back button functionality. • Deleting old values. • Uncontrolled growth. • What happens with AJAX calls.

More Related