Dynamic Composite Controls And Their Child Control Collection

H

Harry

Hello,
I have a composite WebControl that I'm dynamically instantiating at
runtime using Reflection. When I create a new instance of my control I
immediately iterate through it's child control collection (it has
about 4 child controls). The problem is none of these controls are
loaded or accessible when I create the instance since, I believe, they
are created by the server at a later point in time. How could I force
my composite control to load its child controls so I can perform my
iteration?

I don't have this problem when dealing with UserControls as the
LoadControl method creates a new instance of the UserControl and loads
all of it's associated child controls in its control collection.


- Harry
 
B

bruce barker

your composite controls needs to call EnsureChildControls. this will force a
call CreateChildControls.

-- bruce (sqlwork.com)
 
H

Harry

Bruce,
How would I go about doing this? I ahve tried calling the method
this.EnsureChildControls() in my composite WebControl's constructor,
but this doesn't work.

- Harry
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top