difference between Page_Load() and OnLoad() ?

  • Thread starter Thread starter Christian
  • Start date Start date
C

Christian

hi,

what is the difference between the Page_Load() and OnLoad() event handlers.
do they originate from a different point ?
 
OnLoad is a protected method that is raised by the Load
event. I believe this method then calls Page_Load().

Tu-Thach
 
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
 
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.
 
Back
Top