Click here to Skip to main content
13,794,779 members
Click here to Skip to main content


108 bookmarked
Posted 23 Jul 2005
Licenced GPL3

Keep ASP.NET ViewState out of ASPX Page for Performance Improvement

How you could improve performance of your ASP.NET projects, keeping ViewState on the server instead of on the ASPX page.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb" Inherits="ServerViewState.WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="">
        <form id="Form1" method="post" runat="server">
            <P>You <STRONG>MUST</STRONG> have the Microsoft <STRONG>NETSDK</STRONG> installed 
                to see this example.</P>
            <P>This form is inherited directly from <STRONG><FONT color="red" size="4">VSPage</FONT></STRONG>. 
                See on the Navigator the size of Its source code.
            <P>Use the link below to go to the other page, that is inherited from the VSPage 
                <asp:DataGrid id="DataGrid1" runat="server" BorderColor="Tan" BorderWidth="1px" BackColor="LightGoldenrodYellow"
                    CellPadding="2" GridLines="None" ForeColor="Black" AutoGenerateColumns="False" Font-Size="X-Small">
                    <FooterStyle BackColor="Tan"></FooterStyle>
                    <SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
                    <AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
                    <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
                        <asp:BoundColumn DataField="OrderID" SortExpression="OrderID" HeaderText="OrderID"></asp:BoundColumn>
                        <asp:BoundColumn DataField="CustomerID" SortExpression="CustomerID" HeaderText="CustomerID"></asp:BoundColumn>
                        <asp:BoundColumn DataField="EmployeeID" SortExpression="EmployeeID" HeaderText="EmployeeID"></asp:BoundColumn>
                        <asp:BoundColumn DataField="OrderDate" SortExpression="OrderDate" HeaderText="OrderDate"></asp:BoundColumn>
                        <asp:BoundColumn DataField="ShipName" SortExpression="ShipName" HeaderText="ShipName"></asp:BoundColumn>
                        <asp:BoundColumn DataField="ShipAddress" SortExpression="ShipAddress" HeaderText="ShipAddress"></asp:BoundColumn>
                        <asp:BoundColumn DataField="ShipCity" SortExpression="ShipCity" HeaderText="ShipCity"></asp:BoundColumn>
                    <PagerStyle HorizontalAlign="Center" ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Régis Daniel de Oliveira
Web Developer
Brazil Brazil
Régis Daniel is currently living in Itaúna, MG, Brazil. He works with programming since 1999 and actualy works as IT Manager on a wholesaler company. He has experiency as Oracle DBA, and also worked as a PalmOS developer using CodeWarrior with C/C++.
Now a days he works on .NET Framework, developing solutions on Visual Basic.NET and ASP.NET. During his spare time, he likes reading books, watching movies and pratices some outdoor activities, like Trekking and Camping.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.181207.3 | Last Updated 23 Jul 2005
Article Copyright 2005 by Régis Daniel de Oliveira
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid