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: 425
        
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.
- Am I using the correct code to insert the usercontrol?
- Is there an alternative method of insertion available?
- Does the fact that the usercontrol has a page_load make a difference?
- 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