Programatically loading user controls
- by PhilSando
Today's little problem is that I am trying to load user controls from my codebehind like so:
Dim myControl As UserControl = Page.LoadControl("~\Modules\Content.ascx")
Controls.Add(myControl)
On running the page myControl is no where to be seen. I wonder why that is? Well after a bit of thought the following come to mind...
Am I using the correct code to insert the usercontrol?
Is there an alternative available?
Does the fact that the usercontrol has a page_load method make a difference?
Does the fact that the usercontrol is being called from the page_init method make a difference?
Do I need to register the control in my aspx page at design time?
I'll be looking to answer these questions as the day goes on!