In this article we look at one techniques reducing ViewState for Reducing Load Times and
Improving Performance of Website.
Look at the output of any ASP.NET page and you find ViewState. It resembles the following markup when you look at the HTML in the browser.
<input type=”hidden” name=”__VIEWSTATE”
id=”__VIEWSTATE” value=”/wEPDwUL...80sXAJunhsp3aKX6m/d” />
ViewState is how ASP.NET tracks the current settings for all its controls.
You can turn off ViewState for an individual control (for instance, a TextBox) by setting its EnableViewState property to False.
If you are confident that none of the controls on a page will change, you can turn off ViewState for the entire page. In Source view, at the top of the page, add the part that you see shown in bold:
<%@ Page Language=”#” EnableViewState=”false” %>
Going to extremes, if you’re positive that you don’t need ViewState anywhere in the whole ASP.NET site, you can switch it off in the web.config file. Look for the <page> element (somewhere within the <system.web> element) and add the following part shown in bold:
<pages enableViewState=”false”>
0 comments:
Post a Comment