Dynamic adding of usercontrols not showing control on page

Posted by Phil on Stack Overflow See other posts from Stack Overflow or by Phil
Published on 2010-05-27T09:25:49Z Indexed on 2010/05/27 10:11 UTC
Read the original article Hit count: 358

I am trying to insert a user control dynamically into my default.aspx page via the following method in the page_init:

Dim control As UserControl = LoadControl("~\Modules\Content.ascx")
            Controls.Add(control)

When I run the page there is no sign of the usercontrol.

  1. Am I using the correct code to insert the usercontrol?
  2. Is there an alternative method of insertion available?
  3. Does the fact that the usercontrol has a page_load make a difference?
  4. Do I need to register the control in my aspx page at design time?

Thanks in advance for any assistance you can offer.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about usercontrols