473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Overides

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
Nov 18 '05 #1
2 1098
If your class inherits from a Base Class it can use it's methods.
However if you should want to change the method that the base class already
has defined for use in your child class then you can sign it with overrides.
When you call this method on the child class it will not use the method in
the base as it overridden in the child class.

Typical example if your baseclass had a function to add 5 to an integer but
your child class needed to add ten, you could override the base class
function in your child class.

In Child Class***

Overrides Function CalculateSomething(val as Int32) as int32

return val+10

end function

***In BaseClass

Overrides Function CalculateSomething(val as Int32) as int32

return val+5

end function

"Brian Shanon" <bs******@lbrspec.com> wrote in message
news:OV****************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #2
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew | last post by:
Hello, I am trying to set the preferredSize of a panel but am having some problems. I have created a class that extends Panel and included the getPreferredSize method (so it overides the...
0
by: Jason Evans | last post by:
Hi All, I am writing my own implementation of queue via a linked list, note not a LinkedList, and was running into trouble with the clone method. I was wondering if anyone could point out some...
1
by: Li Daobing | last post by:
Hello, I want to use fold-mode or hideshow mode under emacs, but it doesn't work. Cound you tell me how to do this? Thank you. Li Daobing
0
by: Dan McGarry | last post by:
I am in the process of converting a classic COM-based, ASP Application to DotNet. The old application has an embedded, hand-rolled ad-hoc query tool that is kludgy at best. I would like to...
2
by: Paul Wake | last post by:
Why does the first thing work, but the second doesn't? The attempt is to style, for printing purposes, an online document so that when printed it will look like the original article. The original...
4
by: JackRazz | last post by:
I'm trying to use Visual Studio's Find/Replace to match VB declarations. This RegEx works fine in Regulator: ...
6
by: RdS | last post by:
hi, #1 i am looking through some code and have a question. The class I am looking at is a derived class that has one constructor (new). it is coded as: public sub new () .. .. .. end sub
3
by: jhhbr549 | last post by:
Can some help me with this. Please review this code for errors. I can not get it to complie. Here is my Code .. This is an abstract class that is used in conjuntion with 4 other classes.. ...
7
by: colin | last post by:
Hi, I have my property editor wich uses the pop up collection editor for arrays etc, but i have had to use a generic wrapper for the elements in some types of collections. although the editing...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.