Hi Brian,
It's probably most helpful to give you an example. Suppose you have an
ASP.NET page that uses a DataGrid. You have users who complain that when
they are editing fields in the DataGrid, the page takes a very long time to
download. You determine that the cause of this is a very large Viewstate
for the page, but you don't want to turn off Viewstate because your
application relies on it.
In that scenario, you might want to continue to use Viewstate but alter the
way that it works. You could write your own class to maintain state, but
that would be a considerable amount of work and it would not be time
well-spent. After all, ASP.NET already provides all the functionality you
need. You just want to tweak it a bit so that it doesn't load the page
down with all of that Viewstate data. You decide that instead of ASP.NET
sticking all of that Viewstate data in a hidden form field, you want to
make it store it in a Session variable. That's the only change you want to
make. All of the other functionality will remain the same.
There are two methods that are used for Viewstate;
LoadPageStateFromPersistenceMedium (loads Viewstate) and
SavePageStateToPersistenceMedium (saves Viewstate). (You can find
information on both in the SDK help.) If you want to modify the behavior
of Viewstate, you can override both of these functions by doing this:
protected override object LoadPageStateFromPersistenceMedium()
{
return Session["_ViewState"];
}
protected override void SavePageStateToPersistenceMedium(object viewState)
{
Session["_ViewState"] = viewState;
}
In this case, you are telling ASP.NET to use your functionality instead of
the code that the developers of ASP.NET wrote into these functions.
Hope that helps.
Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
ja******@online.microsoft.com
This post is provided "AS-IS" with no warranties and confers no rights.
--------------------
From: "Brian Shannon" <bs******@lbrspec.com>
Subject: Overides
Date: Tue, 10 Aug 2004 09:16:35 -0500
Lines: 9
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <OV**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 209-253-97-242.ip.mcleodusa.net 209.253.97.242
Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTF EED01.phx.gbl!TK2MSFTNGP08
.phx.gbl!tk2msftngp13.phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:253368
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
I see code that uses the overrides. I am having a hard time understanding
what it means. Can someone explain or point me somewhere to read on using
Overrides.
A commone one I see is Overriding the Base page class.
Thanks