CreateChildControls?

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

William F. Robertson, Jr.

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
 
W

William F. Robertson, Jr.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top