Dynamic loading of Web User Controls into a Content/ContentPlaceHo

Discussion in 'ASP .Net' started by =?Utf-8?B?V291dGVy?=, Feb 25, 2006.

  1. 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
     
    =?Utf-8?B?V291dGVy?=, Feb 25, 2006
    #1
    1. Advertising

  2. In the markup:
    <asp:placeHolder id="phDynamicControls" runat="server"></asp:placeHolder>
    In the Page_Init event:
    phDynamicControls.Controls.Add(LoadControl("WebUsercontrol.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
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Feb 25, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hazz
    Replies:
    6
    Views:
    49,790
    SkyUCHC
    Jun 9, 2010
  2. Bob Rock
    Replies:
    1
    Views:
    664
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
  3. Tor Inge Rislaa

    Loading flash content into a web page

    Tor Inge Rislaa, Apr 18, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    398
    Tor Inge Rislaa
    Apr 19, 2007
  4. =?Utf-8?B?QU5lZWxpbWE=?=

    Loading custom user controls into asp.net 2.0 wizard help

    =?Utf-8?B?QU5lZWxpbWE=?=, Oct 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    723
    Mike Placentra II
    Oct 3, 2007
  5. Kurt
    Replies:
    0
    Views:
    194
Loading...

Share This Page