When Page.OnInit is done and exited, can I be sure that ALL child controls have called OnInit as wel

Discussion in 'ASP .Net' started by Sally, Apr 14, 2004.

  1. Sally

    Sally Guest

    Just confused about when OnInit and Constructor gets called in the
    parent/child case.


    Page.Constructor()
    Page.AddParsedSubObject() <- do all the sub's constructors get called
    here?
    Page.OnInit() Children.OnInit() (from what I have read, no particular
    oder)

    So where does CreateChildControls() come in and when
    CreateChildControls() is done, does that mean that all
    Children.OnInit() have been called?
     
    Sally, Apr 14, 2004
    #1
    1. Advertising

  2. Sally

    bruce barker Guest

    in short no.

    CreateChildControls is deferred for as long as possible. If your control
    does not call EnsureChildControls (say no postback or viewstate handling
    required), then it may not get called until PreRender (well after OnLoad).

    AddParsedSubObject(), is used by the aspx parser to notify your control that
    is parsed a control nested inside yours. your control is supposed to decide
    what to do with this control. you may add it to your controls Controls
    collection right away, or defer until CreateChildControls() is called if
    needed.

    OnInit is called close to control creation, but there is no control of the
    timing. your controls children may be created first or after. as your
    CreateChildControls() can create new controls on its own, this will not have
    been Init'd yet.



    -- bruce (sqlwork.com)


    "Sally" <> wrote in message
    news:...
    > Just confused about when OnInit and Constructor gets called in the
    > parent/child case.
    >
    >
    > Page.Constructor()
    > Page.AddParsedSubObject() <- do all the sub's constructors get called
    > here?
    > Page.OnInit() Children.OnInit() (from what I have read, no particular
    > oder)
    >
    > So where does CreateChildControls() come in and when
    > CreateChildControls() is done, does that mean that all
    > Children.OnInit() have been called?
     
    bruce barker, Apr 15, 2004
    #2
    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. Invalidlastname
    Replies:
    7
    Views:
    822
    Steven Cheng[MSFT]
    Jan 16, 2004
  2. Tomas
    Replies:
    1
    Views:
    3,144
    Teemu Keiski
    Feb 8, 2004
  3. Replies:
    0
    Views:
    561
  4. gamename

    Not Sure This Can Be Done...

    gamename, Apr 1, 2008, in forum: Python
    Replies:
    6
    Views:
    239
    gamename
    Apr 9, 2008
  5. Replies:
    0
    Views:
    209
Loading...

Share This Page