473,402 Members | 2,055 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,402 software developers and data experts.

Difference between Page_Load and OnLoad

Hi everybody,

sorry for the newbie question but I can't get the difference between
these two code snippets. Is it that one is a delegate (the first) and
that while the first ADDS behaviour the other completely rewrites it?

Thanks,
Lorenzo

public partial class AdminPage : Page
{
protected void Page_Load(object sender, EventArgs e){//something here}
}
---
public partial class AdminPage : Page
{
protected override void OnLoad(EventArgs e){//something here}
}

Nov 19 '05 #1
3 2630
You are correct. The really provide the same functionality to the code, but
only the class itself can implement OnLoad. Anything outside must use the
Load event and map it to a method. If you use the OnLoad method, you must
call the base class's OnLoad, otherwise the event handlers will not be
called.

<lb********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi everybody,

sorry for the newbie question but I can't get the difference between
these two code snippets. Is it that one is a delegate (the first) and
that while the first ADDS behaviour the other completely rewrites it?

Thanks,
Lorenzo

public partial class AdminPage : Page
{
protected void Page_Load(object sender, EventArgs e){//something here}
}
---
public partial class AdminPage : Page
{
protected override void OnLoad(EventArgs e){//something here}
}

Nov 19 '05 #2
Peter Rilling wrote:
You are correct. The really provide the same functionality to the code, but
only the class itself can implement OnLoad. Anything outside must use the
Load event and map it to a method. If you use the OnLoad method, you must
call the base class's OnLoad, otherwise the event handlers will not be
called.


Hi Peter,

thanks for the reply

Lorenzo

Nov 19 '05 #3
Yes,

Load is the event and OnLoad is a method that raises that event when called
it's just base class implementation that does it of course, and therefore
needs to be called from deriving classes so that events work)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
..

<lb********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi everybody,

sorry for the newbie question but I can't get the difference between
these two code snippets. Is it that one is a delegate (the first) and
that while the first ADDS behaviour the other completely rewrites it?

Thanks,
Lorenzo

public partial class AdminPage : Page
{
protected void Page_Load(object sender, EventArgs e){//something here}
}
---
public partial class AdminPage : Page
{
protected override void OnLoad(EventArgs e){//something here}
}

Nov 19 '05 #4

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

Similar topics

13
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
3
by: Christian | last post by:
hi, what is the difference between the Page_Load() and OnLoad() event handlers. do they originate from a different point ?
3
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
2
by: foldface | last post by:
Hi I am aware of how Page_Load and OnLoad work. What I am curious about is -why- there are 2 mechanisms for doing the same thing, in particular why Visual Studio will generate code to implement...
0
by: RAJ | last post by:
This event appears to be invoked twice for absolutely no reason on only one of my ASP.Net web user controls. Although I've now overcome the problem by overriding the base classes OnLoad routine, I...
2
by: RAJ | last post by:
Posting this thread again, can somebody please help me with this. Thanks. This event appears to be invoked twice for absolutely no reason on only one of my ASP.Net web user controls. Although...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
3
by: doobdave | last post by:
Hi all, I'm experiencing a rather strange problem: I am coding a web application using VB.net ASP.net and Visual Studio 2003. It's quite a large application, but the problem only occurs on...
2
by: Dave | last post by:
Hi, this is a follow-up to an earlier question but I really haven't found a definitive answer in my search If I have a Base and Derived webform, I've found that the dervived Page_Load event...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.