Can you load a usercontrol into another usercontrol?

Discussion in 'ASP .Net' started by COHENMARVIN@lycos.com, May 13, 2008.

  1. Guest

    I have an aspx page that loads a usercontrol. Can that usercontrol
    load another usercontrol into part of it?
    Thanks,
    Marv
    , May 13, 2008
    #1
    1. Advertising

  2. Sure, why not....

    George.

    <> wrote in message
    news:...
    >I have an aspx page that loads a usercontrol. Can that usercontrol
    > load another usercontrol into part of it?
    > Thanks,
    > Marv
    George Ter-Saakov, May 13, 2008
    #2
    1. Advertising

  3. Yes, just keep in mind that you need to time your events well in the control
    event hierarchy. Sometimes an action in a usercontrol that works when
    embedded in a page may be a bit off when placed inside another user control.
    For example, you pass data from a usercontrol to another one that will show
    some more data. You click a link in the parent usercontrol to select a
    different set of data to show in the child usercontrol, but the timing of
    the events is off so the child usercontrol doesn't update properly and ends
    up a step behind the parent.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Expression

    <> wrote in message
    news:...
    > I have an aspx page that loads a usercontrol. Can that usercontrol
    > load another usercontrol into part of it?
    > Thanks,
    > Marv
    Mark Fitzpatrick, May 13, 2008
    #3
  4. Arthur Guest

    how do you want to load it?
    1.dynamicaly in code behind or
    2.insert usercontrol tag in aspx/ascx code?

    ad 1)
    place the folowing directive in the asp code of the parent page or
    usercontrol:

    <%@ Reference Control="~/Name_of_your_child_control.ascx" %>


    create a new instance in code behind by the following code:

    Name_of_your_child_control control = (Name_of_your_child_control)
    TemplateControl.LoadControl("~/Name_of_your_child_control.ascx");



    ad 2)
    place the folowing directive in the asp code of the parent page or
    usercontrol:

    <%@ Register src="Name_of_your_child_control.ascx"
    tagname="Name_of_your_child_control" tagprefix="uc1" %>


    use the following tag in the asp-code of the parent page/control:

    <uc1:Name_of_your_child_control ID="Name_of_your_child_control1"
    runat="server" />
    Arthur, Jun 23, 2008
    #4
    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. huobazi
    Replies:
    1
    Views:
    667
    David Waz...
    Jul 3, 2003
  2. nail
    Replies:
    0
    Views:
    1,529
  3. Phl
    Replies:
    2
    Views:
    511
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=
    Nov 18, 2004
  4. Fabiano
    Replies:
    2
    Views:
    581
    =?Utf-8?B?c3Jpbmk=?=
    Jun 3, 2005
  5. SlimFlem
    Replies:
    1
    Views:
    356
    Peter Rilling
    Dec 2, 2005
Loading...

Share This Page