Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Loading user control from server control

Reply
Thread Tools

Loading user control from server control

 
 
Petr PALAS
Guest
Posts: n/a
 
      01-06-2005
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.
************************************************** ******************************


 
Reply With Quote
 
 
 
 
Petr PALAS
Guest
Posts: n/a
 
      01-06-2005
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.
> ************************************************** ******************************
>



 
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
Dynamically loading user control from current control davidr@sharpesoft.com ASP .Net 0 09-11-2006 09:02 PM
Loading Dynamic User Control Error: "The control must be placed inside a form tag with runat=server" Help Please Second time posting. davidr@sharpesoft.com ASP .Net 0 08-31-2006 05:26 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Loading user control when a link is clicked on another user contro =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 1 11-18-2005 03:00 AM
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov ASP .Net 2 10-16-2005 08:35 AM



Advertisments