Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic loading of Web User Controls into a Content/ContentPlaceHo

Reply
Thread Tools

Dynamic loading of Web User Controls into a Content/ContentPlaceHo

 
 
=?Utf-8?B?V291dGVy?=
Guest
Posts: n/a
 
      02-25-2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      02-25-2006
In the markup:
<asplaceHolder id="phDynamicControls" runat="server"></asplaceHolder>
In the Page_Init event:
phDynamicControls.Controls.Add(LoadControl("WebUse rcontrol.ascx"));
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Wouter" wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading custom user controls into asp.net 2.0 wizard help =?Utf-8?B?QU5lZWxpbWE=?= ASP .Net 1 10-03-2007 12:11 AM
Issues in ASP.NET 2.0 when dynamically loading user controls or asp.net web controls??? Bob Rock ASP .Net 1 09-17-2006 01:49 PM
Dynamic Controls created by Dynamic Controls Ronald ASP .Net 2 01-17-2006 12:44 AM
Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls Denny Smolinski via .NET 247 ASP .Net Web Controls 1 05-04-2004 09:15 PM
Loading Different User Controls into a Single DataGrid Mark ASP .Net Datagrid Control 3 12-10-2003 01:40 AM



Advertisments