In ASP.NET, as you may already know, you can set most of the Page Directives at the web.config Pages section if you need these directives to apply to all pages contained in your Web application.
So setting EnableViewState to false, for example, in web.config’s Pages section means that none of your page will use ViewState to persist state for its controls. So “what happens if I have an exception, a page that needs viewstate” you might ask.
In most of the cases setting the corresponding directive’s value at the Page declaration normally overrides the global web.config one, but that’s not the case with EnableViewState. If this directive is set to the web.config file, then no matter what you type on the Page won’t change the globally set value.
If you have an exception then you’ll have to remove the global setting completely and specify the directive at each web form in your web application.
So now you’ll know what’s going on next time you’ll find yourself searching why on earth viewstate is disabled even though you’ve explicitly set EnableViewState=”true” at the Page directive.
Be First to Comment