467,145 Members | 949 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,145 developers. It's quick & easy.

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

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?
Nov 18 '05 #1
  • viewed: 2109
Share:
1 Reply
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" <po**************@yahoo.com> wrote in message
news:ff**************************@posting.google.c om...
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?

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by szabelin | last post: by
1 post views Thread by John Blair | last post: by
1 post views Thread by R2D2 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.