Personal Web & Sample Site
Skip Navigation Links
About Me |
| Contact Us
ASP.Net - View State
Rating: 6 user(s) have rated this article Average rating: 5.0
Posted by: joet, on 9/5/2011, in category "ASP.NET"
Views: this article has been read 2418 times
Location: Houston, Tx, United States
Abstract: What is VIEWSTATE in ASP.Net? In my own words, VIEWSTATE is a technique used in ASP.Net that persists values for any control on a given page. By default a control's viewstate is set to true but you can disable it by setting it's property to false.


What is VIEWSTATE in ASP.Net? In my own words, VIEWSTATE is a technique used in ASP.Net that persists values for any control on a given page. By default a control's viewstate is set to true but you can disable it by setting it's property to false. There are many events that can be raised in a ASP.Net page and anytime an event is raised it fires a postback. Once the postback is sent to the web server it's job is to process this request and then send back a response to the user's browser. How is it supposed to keep track of information in a given control when it sends back another version of the page? Or repopulate the fields? 

There is a hidden field used on every ASP.Net page that holds the contents of the controls, or view state collection, thats serialized into a blob of base-64 encoded text. If you visit an ASP.Net page you can click on view and on the dropdown menu click source. This will display the source file for that page and you will see the hidden field and its encoded contents.


This is better than session state because it doesn't use server resources to save temporary values because the values are saved as part of the overall page.


The problem with View State is that it can be disabled, by setting the page's or control's EnableViewState property to False.

How would you rate this article?

User Feedback

Post your comment
Insert Cancel

Copyright © 2013 Jose M. Tamez
Last Updated August 18th 2013