Loading user control from server control

Discussion in 'ASP .Net Web Controls' started by Petr PALAS, Jan 6, 2005.

  1. Petr PALAS

    Petr PALAS Guest

    Hello,

    I'm trying to load a user control (ASCX) from server control (*.vb) and
    display it on the page. The user control is displayed, but its postback
    events do not work - when I press a button, nothing happens.

    When I load the same user control directly from an ASPX page using the
    Page.LoadControl method, everything works fine.

    The server control looks like this:

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
    EnsureChildControls()
    mControl.RenderControl(output)
    End Sub

    Protected Overrides Sub CreateChildControls()
    mControl = Page.LoadControl("mycontrol.ascx")
    Me.Controls.Add(mControl)
    End Sub

    Any idea where I make the error?

    Thank you.

    Best Regards,

    Petr Palas
    ********************************************************************************
    Kentico Software
    WWW: www.kentico.com
    Blog: www.kentico.com/blog
    Kentico CMS - The most affordable CMS for ASP.NET professionals.
    ********************************************************************************
    Petr PALAS, Jan 6, 2005
    #1
    1. Advertising

  2. Petr PALAS

    Petr PALAS Guest

    Sorry, I've just solved this: I needed to add

    Implements INamingContainer

    Regards,

    Petr Palas
    ********************************************************************************
    Kentico Software
    WWW: www.kentico.com
    Blog: www.kentico.com/blog
    Kentico CMS - The most affordable CMS for ASP.NET professionals.
    ********************************************************************************


    "Petr PALAS" <> wrote in message
    news:%23dIPro$...
    > Hello,
    >
    > I'm trying to load a user control (ASCX) from server control (*.vb) and
    > display it on the page. The user control is displayed, but its postback
    > events do not work - when I press a button, nothing happens.
    >
    > When I load the same user control directly from an ASPX page using the
    > Page.LoadControl method, everything works fine.
    >
    > The server control looks like this:
    >
    > Protected Overrides Sub Render(ByVal output As
    > System.Web.UI.HtmlTextWriter)
    > EnsureChildControls()
    > mControl.RenderControl(output)
    > End Sub
    >
    > Protected Overrides Sub CreateChildControls()
    > mControl = Page.LoadControl("mycontrol.ascx")
    > Me.Controls.Add(mControl)
    > End Sub
    >
    > Any idea where I make the error?
    >
    > Thank you.
    >
    > Best Regards,
    >
    > Petr Palas
    > ********************************************************************************
    > Kentico Software
    > WWW: www.kentico.com
    > Blog: www.kentico.com/blog
    > Kentico CMS - The most affordable CMS for ASP.NET professionals.
    > ********************************************************************************
    >
    Petr PALAS, Jan 6, 2005
    #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. Tim
    Replies:
    7
    Views:
    482
    bruce barker
    Oct 29, 2004
  2. Leeor Chernov
    Replies:
    2
    Views:
    789
    Leeor Chernov
    Oct 16, 2005
  3. =?Utf-8?B?U3JpZGhhcg==?=
    Replies:
    1
    Views:
    453
    =?Utf-8?B?RWx0b24gVw==?=
    Nov 18, 2005
  4. Replies:
    0
    Views:
    2,058
  5. Replies:
    0
    Views:
    410
Loading...

Share This Page