Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one have idea about why once the EnableViewState="false" is set to false view source for aspx page shows the below view state.
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="gJs0425FICttUP7HUFVIiGk3ec5UOXNElJPQxzcmp8a2MYq3SDYtnAjg+oV3NP/golCXYP5a3tiX0MZasdOskUasZpRIrlE3YVWbEiomPVk=" />
Posted
Updated 26-Jan-16 3:07am
v2

You always have the viewstate, setting it false on your page just means your controls don't persist their state automatically. If you want to get rid of the hidden field altogether you'll need to remove it from the output stream. There are various articles on how you can do this if you really want to.
 
Share this answer
 
'EnableViewState' property is used to indicate whether the server control persists its view state, and the view state of any child controls it contains. it has nothing to do with the text exist in '__VIEWSTATE' in page source.
It is true that 'EnableViewState' set to 'false' will decrease the content size of '__VIEWSTATE' text.
if you want to completely remove the text from '__VIEWSTATE' you can add below events in page load

C#
 protected override void SavePageStateToPersistenceMedium(object state)
{
    //base.SavePageStateToPersistenceMedium(state);
}

protected override object LoadPageStateFromPersistenceMedium()
{
    return null; //return base.LoadPageStateFromPersistenceMedium();
}

protected override object SaveViewState()
{
    return null;// base.SaveViewState();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900