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

aspnet2005: What is Page_Load ?

Hi All!

System.Web.UI.Page
C#

I do not understand what is the Page_Load method. I supose it is an event
handler for the Page.Load event, but I cannot find any association between
the event Page.Load and the method Page_Load.

I expected to find somewhere something like :
this.Load+=new EventHandler(this.Page_Load);

Can someone help me to understand how this method is called ?

Ernest
Mar 7 '06 #1
7 1686
The ASP.NET page framework also supports an automatic way to associate
page events and methods. If the AutoEventWireup attribute of the Page
directive is set to true (or if it is missing, since by default it is
true), the page framework calls page events automatically, specifically
the Page_Init and Page_Load methods. In that case, no explicit Handles
clause or delegate is needed. [1]

[1]
http://msdn.microsoft.com/library/de...EventModel.asp

Mar 7 '06 #2
In your @Page directive, there's an attribute called AutoWireUp when this
is true (which is the default behaviour in 2005), the compiler automatically
looks for certain method names and hooks them up. So internally, Page_Load
gets hooked into the Load event automatically.

Many of us prefer a different approach, set AutoWireUp to false and override
the onLoad event..

Karl

--
http://www.openmymind.net/

"Ernest Morariu" <er****@gesora.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All!

System.Web.UI.Page
C#

I do not understand what is the Page_Load method. I supose it is an event
handler for the Page.Load event, but I cannot find any association between
the event Page.Load and the method Page_Load.

I expected to find somewhere something like :
this.Load+=new EventHandler(this.Page_Load);

Can someone help me to understand how this method is called ?

Ernest

Mar 7 '06 #3
re:
I expected to find somewhere something like :
this.Load+=new EventHandler(this.Page_Load);

Can someone help me to understand how this method is called ?
In this page you'll find the answer to your questions :

"How to use the AutoEventWireup attribute in an ASP.NET Web Form"
http://support.microsoft.com/default...b;en-us;324151

Essentially, if you use AutoEventWireup="true",
you don't need to use the EventHandler code.

The Page_Load event is ideal for user code initialization:
http://msdn.microsoft.com/library/de...ToWebForms.asp

General info on ASP.NET internals is found at :
http://msdn.microsoft.com/library/de.../Internals.asp


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Ernest Morariu" <er****@gesora.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hi All!

System.Web.UI.Page
C#

I do not understand what is the Page_Load method. I supose it is an event handler for the
Page.Load event, but I cannot find any association between the event Page.Load and the method
Page_Load.

I expected to find somewhere something like :
this.Load+=new EventHandler(this.Page_Load);

Can someone help me to understand how this method is called ?

Ernest

Mar 7 '06 #4
Many thanks to all of you !

Ernest

"Ernest Morariu" <er****@gesora.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All!

System.Web.UI.Page
C#

I do not understand what is the Page_Load method. I supose it is an event
handler for the Page.Load event, but I cannot find any association between
the event Page.Load and the method Page_Load.

I expected to find somewhere something like :
this.Load+=new EventHandler(this.Page_Load);

Can someone help me to understand how this method is called ?

Ernest

Mar 7 '06 #5
Hi Karl

Karl Seguin [MVP] wrote:

Many of us prefer a different approach, set AutoWireUp to false and override
the onLoad event..

Karl


I would be interested to know what the advantages are to wire your
events yourself, instead of using AutoWireUp. Can you elaborate?

Thanks a lot,
Laurent
Mar 8 '06 #6
Well, I've heard that there's a performance hit associated witht he
automatic hook up. It's probably quite trivial and I'd consider that an
unecessary micro-optimization. The real reason I do it is because
AutoWireUp is too obscur. It abstracts away well a understood and
established model - overriding and calling the base implementation. This can
lead to subtle bugs (in 1.1 a lot of people have page_load mysteriously fire
twice) as well as a harder-than-necesasry code to maintain. I've changed
my default templates so that AutoWireUp is false and my codebehind
automatically has the override code...so it's doesn't take me any more time.

I just don't see why this one case should be different than everything else
karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Laurent Bugnion" <ga*********@bluewin.ch> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Karl

Karl Seguin [MVP] wrote:

Many of us prefer a different approach, set AutoWireUp to false and
override the onLoad event..

Karl


I would be interested to know what the advantages are to wire your events
yourself, instead of using AutoWireUp. Can you elaborate?

Thanks a lot,
Laurent

Mar 8 '06 #7
Hi Karl,

Karl Seguin [MVP] wrote:
Well, I've heard that there's a performance hit associated witht he
automatic hook up. It's probably quite trivial and I'd consider that an
unecessary micro-optimization. The real reason I do it is because
AutoWireUp is too obscur. It abstracts away well a understood and
established model - overriding and calling the base implementation. This can
lead to subtle bugs (in 1.1 a lot of people have page_load mysteriously fire
twice) as well as a harder-than-necesasry code to maintain. I've changed
my default templates so that AutoWireUp is false and my codebehind
automatically has the override code...so it's doesn't take me any more time.

I just don't see why this one case should be different than everything else
karl


Interesting. Thanks for the food for my thoughts ;-)

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Mar 8 '06 #8

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

Similar topics

1
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes...
3
by: DavidS | last post by:
Have parent.aspx from which I open Driver.aspx form via button on parent.aspx. When I first open the modal dialog, the driver.aspx Page_Load function is called. After I close the dialog, then...
0
by: Itai | last post by:
Background: I have four Web Form pages with respective C# code behind files, all in the same project: localhost/vpath1 Page1.aspx Page2.aspx
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) {...
4
by: tshad | last post by:
Is there a way to do put Page_loads on a page? I am trying to setup a Page_Load that just puts a persons name that is logged on at the top of a page the first time a page is loaded. In my...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
1
by: rockdale | last post by:
Hi, I have a masterpage and on the page_load event I Populate my mainmenu from database. I the page_load event of my content, I am trying to programmly select the menuitem that represent...
11
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.