Only use ViewState when necessary
ViewState is enabled by default, using it can significantly increase the amount of data rendered by your page. So it is recommended to disable it when it is not needed, especially when you use data-bound controls, all of which use view state to save their state across post backs.
Viewstate is useful, whenever a page posts back to itself. If this is not the case, it is convenient to disable the ViewState.
You can selectively disable the VIEWSTATE of the controls, DataGrids etc that you use on the page if these controls do not post back to the same page.
Set the ScriptManager LoadScriptsbeforeUI property to false.
If you are using WebForms with Microsoft Ajax, you can set the LoadScriptsBeforeUI property of the ScriptManager control to false.
This property value is true by default. In that case, the manager will render each referenced script using the ScriptManager at the top of your HTML.
If the property is set to false, the manager will render the scripts at the bottom of your HTML.
Browsers stop parsing and rendering HTML when they are downloading and executing scripts. Therefore, having the scripts at the bottom improves the perceived performance (especially if your scripts are big), because the whole HTML will be renderer first.
Combine Client Scripts into a Composite Script
The following code shows how to combine some scripts using the ScriptManager control.
<form id=”form1″ runat=”server”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
<asp:ScriptReference Path=”~/Scripts/Script1.js” />
<asp:ScriptReference Path=”~/Scripts/Script2.js” />
<asp:ScriptReference Path=”~/Scripts/Script3.js” />
<p>This example shows how to combine multiple client scripts into
a single composite script.</p>
<input id=”Button1″ type=”button” value=”Button 1″ onclick=”buttonClick1()” />
<span id=”Span1″></span><br /><br />
<input id=”Button2″ type=”button” value=”Button 2″ onclick=”buttonClick2()” />
<span id=”Span2″></span><br /><br />
<input id=”Button3″ type=”button” value=”Button 3″ onclick=”buttonClick3()” />
Minimize the content of the UpdatePanel to reduce ViewState
ViewState should be used only when you need to persist changes to the state of a Web Form across postbacks.
When a postback occurs in an UpdatePanel the page’s entire ViewState is passed to the server, updated, and then the updates are passed back down to the browser. So the size of your page’s ViewState has a considerable effect on the performance of your UpdatePanel postbacks.
The recommendation is to minimize the content of the UpdatePanel: the <ContentTemplate> should only include controls that are necessary to refresh.
Note: For more information about this, see Update Panel Challenges .
Use UpdatePanels when using Custom Validators
If you need to perform cross-field validation in the server, consider using a CustomValidator control inside an UpdatePanel control. By placing the validator inside an UpdatePanel, you avoid full postbacks; therefore, the UI’s responsiveness improves.