Hi everyone!.
Is it better for performance to set EnableViewState to false for all pages and just except some controls that i want to enable their ViewState ?.
And how could i do this in web.config file ?.
Hi everyone!.
Is it better for performance to set EnableViewState to false for all pages and just except some controls that i want to enable their ViewState ?.
And how could i do this in web.config file ?.
Absolutely. Disable viewstate whenever possible. :)
Be defensive. Turn it off until you know you need it. :) Good practice in my opinion.
Try this in the web.config under system.web
<pages EnableViewState="false" />
As for if it's better: ASP.NET doesn't make it easy when you turn ViewState off even though some of the more basic controls (e.g., TextBoxes) seem to maintain their state with or without ViewState. Your mileage may vary here, but bear in mind that you're trading performance for code complexity when you turn it off.
You will gain in two areas:
The first point is probably where you will gain most though (in perceived performance that is)