Hi....
Ques: Hello all of you now i am work state management in asp.net but i am not understand What is the difference between EnableViewState and ViewStateMode properties. Please expline....
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anuja PawarPosted Dec 28, 2011, 2:42 AM
What if you turn off ViewState at page level and make it on at control level? Ask yourself, is it possible with previous versions of .NET (upto 3.5)? Sorry but there is a bad news that it's not possible. But there is a good news as well. You can achieve this with new version of ASP.NET that is 4.0.
ASP.NET 4.0 comes with new and cool property ViewStateMode. It has 3 possible values.
The main difference between EnableViewState and ViewStateMode property is, if EnableViewStateproperty is set to disabled at parent level, there is no way of making viewstate enable at control level, But this is possible with this new property :ViewStateMode.
Priya LingePosted Dec 27, 2011, 11:41 PM
1. Using EnableViewState property we only have 2 options
We can turn off view state altogether,
or
Enable viewstate for the entire page and then turn it off on a control-by-control basis.
2. If you want to turn of ViewState for the entire page and only enable it for specific controls on the page, then we have to use ViewStateMode property in conjunction with EnableViewState.
3. EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property.
4. ViewStateMode property is introduced in ASP.NET 4, where as EnableViewState exists from a long time.
5. If EnableViewState is to True, only then the ViewStateMode settings are applied, where as, if EnableViewState is set to False then the control will not save its view state, regardless of the ViewStateMode setting. In short if EnableViewState is set to False, ViewStateMode setting is not respected.
6. To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.
Thanks.Satyapriya NayakPosted Dec 27, 2011, 10:53 PM
Using EnableViewState property we only have 2 options.We can turn off view state altogether.
Enable viewstate for the entire page and then turn it off on a control-by-control basis.
If you want to turn of ViewState for the entire page and only enable it for specific controls on the page, then we have to use ViewStateMode property in conjunction with EnableViewState.
EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property.
ViewStateMode property is introduced in ASP.NET 4, where as EnableViewState exists from a long time.
If EnableViewState is to True, only then the ViewStateMode settings are applied, where as, if EnableViewState is set to False then the control will not save its view state, regardless of the ViewStateMode setting. In short if EnableViewState is set to False, ViewStateMode setting is not respected.
To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.
Refer
http://venkataspinterview.blogspot.com/2011/12/difference-between-enableviewstate-and.html
Thanks