OnInit and Page_Init

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Oct 29, 2007.

  1. hey all,
    Is OnInit and Page_Init the same thing?

    thanks,
    rodchar
     
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 29, 2007
    #1
    1. Advertising

  2. 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.

    --
    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
     
    Peter Bucher [MVP], Oct 30, 2007
    #2
    1. Advertising

  3. Thank you Peter for the insight.
    Rod.

    "Peter Bucher [MVP]" wrote:

    > 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.
    >
    > --
    > 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
    >
    >
    >
     
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 30, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    2
    Views:
    583
    Natty Gur
    Jul 13, 2003
  2. Guest
    Replies:
    2
    Views:
    3,142
    Guest
    Jul 16, 2003
  3. Christian

    Page_Init() and Page_Load()

    Christian, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    709
    Cristian Suazo
    Jul 16, 2003
  4. Sally
    Replies:
    1
    Views:
    497
    bruce barker
    Apr 15, 2004
  5. harry potter

    Should I use Page_Init or OnInit method.

    harry potter, Feb 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,521
Loading...

Share This Page