M
Michael
Hi,
I'm coding a custom server control, and CreateChildControls() is giving me
some pain. I'm just wondering why we have CreateChildControls(), and why
this methods seems to be called at different times in the page lifecycle. I
mean the order it is called is not deterministic. Example if not post back,
then my CreateChildControls() is being executed before my Load event. But
for post back, my Load event executes before my CreateChildControls().
I suppose calling EnsureChildControls() will call CreateChildControls() if
it has not already been called. But why all this complication? I'm even
thinking about creating my controls in the constructor instead of inside
CreateChildControls(); at least this way I know that my controls will have
been created when I need to use them.
I'm coding a custom server control, and CreateChildControls() is giving me
some pain. I'm just wondering why we have CreateChildControls(), and why
this methods seems to be called at different times in the page lifecycle. I
mean the order it is called is not deterministic. Example if not post back,
then my CreateChildControls() is being executed before my Load event. But
for post back, my Load event executes before my CreateChildControls().
I suppose calling EnsureChildControls() will call CreateChildControls() if
it has not already been called. But why all this complication? I'm even
thinking about creating my controls in the constructor instead of inside
CreateChildControls(); at least this way I know that my controls will have
been created when I need to use them.