Any way to access child controls of server control?

S

Seth Petry-Johnson

Is there a way to compile a user control into a redistributable
assembly [i.e. server control], but still have access to its child
controls using the .Controls property?

Here's what I mean:

I have a user control that contains some child controls, mostly custom
text boxes and such. If I load this control declaratively or using
LoadControl(), I can access those child controls using the .Controls
property.

However, I need this control to be redistributable, ideally as a .dll.
I found a blog post [http://blogs.msdn.com/davidebb/archive/
2005/10/30/487160.aspx] that explains how the user control can be
compiled into an assembly that can then be used just like a server
control.

That technique works fine, except that when I load the control I can
no longer iterate those child controls; the .Controls property returns
an empty collection.

Anyone have any suggestions?

Thanks so much in advance,
Seth Petry-Johnson
 
S

Seth Petry-Johnson

Is there a way to compile a user control into a redistributable
assembly [i.e. server control], but still have access to its child
controls using the .Controls property?

Nevermind, answered my own question. I was loading the compiled
control using its constructor, not LoadControl(). When I used
LoadControl(typeof(mycontrol), null) it works fine.
 

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

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top