Dynamic loading of Web User Controls into a Content/ContentPlaceHo

G

Guest

Hi,

I hope somebody can give me a pointer to solve the following problem.

I want to dynamically load a web usercontrol (ascx) into a content control
of a content page which references a master page.

I have tried to place a PlaceHolder control first in the content section and
then load the user control and add it to the controls collection of the
PlaceHolder but the problem stays the same, the user control is not
displayed.

The code executes with out problem and while debugging I can see that the
user control is added to the collection but it never shows up on the rendered
page.

What am I doing wrong?

Thanks,

P.S. I am talking of course about the .NET 2.0 version
 
G

Guest

In the markup:
<asp:placeHolder id="phDynamicControls" runat="server"></asp:placeHolder>
In the Page_Init event:
phDynamicControls.Controls.Add(LoadControl("WebUsercontrol.ascx"));
 

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

Latest Threads

Top