OnInit and Page_Init

P

Peter Bucher [MVP]

Hello Rodchar
Is OnInit and Page_Init the same thing?
There are 3 different things.

"Init" is the event
"OnInit" is the method that raises the "Init" event
"Page_Init" (Or some else name) is the name of the eventhandler that is
attached to an (typically Init) event

If you want to handle the event, you can:

1. Wire up the Init Event and handle the event in a eventhanler methode (for
example: Page_Init)
2. Overwrite the "OnInit" method and implement some logic in there,
additionaly you can (or in some cases should) call the base.OnInit()
method, otherwise the implementation of the base class would`t run.
 
G

Guest

Thank you Peter for the insight.
Rod.

Peter Bucher said:
Hello Rodchar

There are 3 different things.

"Init" is the event
"OnInit" is the method that raises the "Init" event
"Page_Init" (Or some else name) is the name of the eventhandler that is
attached to an (typically Init) event

If you want to handle the event, you can:

1. Wire up the Init Event and handle the event in a eventhanler methode (for
example: Page_Init)
2. Overwrite the "OnInit" method and implement some logic in there,
additionaly you can (or in some cases should) call the base.OnInit()
method, otherwise the implementation of the base class would`t run.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top