difference between Page_Load() and OnLoad() ?

C

Christian

hi,

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

Tu-Thach

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

Tu-Thach
 
C

Christian

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
 
M

MikeB

Christian said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top