What goes in ViewState when page EnableViewState property is set to false?

I bet that many of you sow that the __viewstate filed still holding data even if all page controls and the page itself EnableViewState property set to false. Well, what’s going on, what is saved by the page in the ViewState although we turn ViewSate off?

To answer this question lets check what value is being saved in ViewState and what he stands for. We will start by overriding SavePageStateToPersistenceMedium method that responsible for saving the ViewState data to persist media (hidden field as default). This method gets an object parameter that is actually Triplet object. Triplet class holds three objects that can be added together to an ASP.NET server control's view state in hierarchical order. For the simplicity of that demonstration let’s talk about a page without any controls that we set it EnableViewState property to false. In this case the triplet object will hold value just in the First member. The First member holds a number, remember that number and continue the page process.

After getting the value preserved in the view state lets see what he means. To do so I’ll use stuffs that I described in “Behind the scenes of ASPX files”. Check the page XML file for it random key and open the RandomKey.cs file. Look for the GetTypeHashCode method in the cs file and you will find that it’s the same number that the page preserve to ViewState. To be more accurate this number is hash code that is unique to the Page object's control hierarchy.

Published Tuesday, December 30, 2003 3:58 PM by nattYGUR

Comments

# re: What goes in ViewState when page EnableViewState property is set to false?

Saturday, February 07, 2004 2:55 PM by sha
I want to disable viewstate . How I can do that?
Even the propery is false it's saving the state

# re: What goes in ViewState when page EnableViewState property is set to false?

Monday, March 08, 2004 12:47 AM by Natty gur
refer to :
http://weblogs.asp.net/ngur/archive/2004/03/08/85876.aspx

# re: What goes in ViewState when page EnableViewState property is set to false?

Friday, March 26, 2004 8:41 AM by zxc
zxczxc

# re: What goes in ViewState when page EnableViewState property is set to false?

Friday, March 26, 2004 8:46 AM by zxc
aSas

# re: What goes in ViewState when page EnableViewState property is set to false?

Sunday, July 08, 2007 3:45 AM by dotnetuncle

Check out this link to know more on the enableviewstate property

www.dotnetuncle.com/.../124_enableviewstate.aspx

# re: What goes in ViewState when page EnableViewState property is set to false?

Wednesday, March 24, 2010 3:08 PM by Fidelity

Hi. When they discover the center of the universe, a lot of people will be disappointed to discover they are not it. Help me! Looking for sites on: Stock trading forum. I found only this - <a href="www.fabrikant-records.net/.../StockTrading">afterhours stock trading</a>. You will buy more things for yourself if you get however in outdoor students, stock trading. Stock trading, full commentary of principles and shares is prior video. With respect ;-), Fidelity from Emirates.

Leave a Comment

(required) 
(required) 
(optional)
(required)