By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

difference between Page_Load() and OnLoad() ?

P: n/a
hi,

what is the difference between the Page_Load() and OnLoad() event handlers.
do they originate from a different point ?

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
OnLoad is a protected method that is raised by the Load
event. I believe this method then calls Page_Load().

Tu-Thach
-----Original Message-----
hi,

what is the difference between the Page_Load() and OnLoad () event handlers.do they originate from a different point ?

.

Nov 17 '05 #2

P: n/a
the strange thing though is that when I implement both functions only
OnLoad()
is invoked and Page_Load() never is ???

same as with OnInit() and Page_Init()

christian

"Nikolaus Hruska" <nh*****@nist.gov> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
Onload raises the Load event.

if you want to selectively fire the Load event, override OnLoad, and check
the necessary conditions.

ex:

Protected Sub OnLoad(sender as object, e as eventargs)

'only fire load event if condition is met
If myCondition = True Then
MyBase.OnLoad()
End If
End Sub

--
Nikolaus R. Hruska
AASHTO Materials Reference Laboratory
National Institute of Standards and Technology
http://amrl.net
nh*****@amrl.net
"Rob Epstein" <re******@auctionworks.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
Christian,

Page_Load() is a private function created by VS.NET that it then ties to
the OnLoad event of the Page class in the InitializeComponents function.
As I understand it, there is no need for this step since OnLoad is a
protected function in the Page class that can be overriden. Just make
sure you call the base OnLoad function in your overloaded version.

Rob Epstein
Sr Developer, AuctionWorks Inc.

Christian wrote:
hi,

what is the difference between the Page_Load() and OnLoad() event handlers. do they originate from a different point ?


Nov 17 '05 #3

P: n/a

"Christian" <ch***************@pandora.be> wrote in message
news:G4******************@afrodite.telenet-ops.be...
the strange thing though is that when I implement both functions only
OnLoad()
is invoked and Page_Load() never is ???
The Page_Load() event handler needs to be added to the Load event of the
page class. If you're using VS.NET the IDE normally adds code that does
this for you at page init time in an override of the OnInit() method (it's
in a region of code marked with a "#region Web Form Designer generated code"
directive).

Another possible problem is that your override of the OnLoad() method is not
calling base.OnLoad() which is where the event handers registered in the
Load event will be called.

same as with OnInit() and Page_Init()

christian

"Nikolaus Hruska" <nh*****@nist.gov> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
Onload raises the Load event.

if you want to selectively fire the Load event, override OnLoad, and check the necessary conditions.

ex:

Protected Sub OnLoad(sender as object, e as eventargs)

'only fire load event if condition is met
If myCondition = True Then
MyBase.OnLoad()
End If
End Sub

--
Nikolaus R. Hruska
AASHTO Materials Reference Laboratory
National Institute of Standards and Technology
http://amrl.net
nh*****@amrl.net
"Rob Epstein" <re******@auctionworks.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
Christian,

Page_Load() is a private function created by VS.NET that it then ties to the OnLoad event of the Page class in the InitializeComponents function. As I understand it, there is no need for this step since OnLoad is a
protected function in the Page class that can be overriden. Just make
sure you call the base OnLoad function in your overloaded version.

Rob Epstein
Sr Developer, AuctionWorks Inc.

Christian wrote:
> hi,
>
> what is the difference between the Page_Load() and OnLoad() event

handlers.
> do they originate from a different point ?
>
>
>




--
MikeB
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.