CreateChildControls?

  • Thread starter Thread starter George Ter-Saakov
  • Start date Start date
G

George Ter-Saakov

Hi.
I have an HTML page were I load controls dynamically.

So I overwrote the CreateChildControl but I found some problem.
First time when page is called the CreateChildControl is called after
Page::Load
But when it's a post back the CreateChildControl is called before
Page::Load.


Is there any reason for that?


George.
 
The CreateChildControls is called in a composite control before the child
controls are needed. The child controls more than likely need to processes
some postback data ( or events ) and thus, they are required to be around
before the page load.

It shouldn't matter when the CreateChildControls is being called as far as
the behavior of your composite control, but I would definitely consider
adding EnsureChildControls() before every method or property that access the
child controls and don't concern your self of the "first" time it is called.

HTH,

bill
 
I can type the EnsureChildControls() really fast since I use it about 4000
times in each of my controls. Typically on the properties for the composite
controls.

happy coding.

bill
 
Back
Top