Today's little problem is that I am trying to load user controls from my codebehind like so:
Dim myControl As UserControl = 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 event make a difference?
- Does the fact that the usercontrol is being called from page_init 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!
Here are my answers so far:
- Yes the code is working. I found this out by adding a static <p> tag to the ascx and found it is in fact being displayed on the page
- The fact that the user control has a page-load is making a difference. I have added Response.write("Test from within page_load") and this is being rendered ... twice
-
-
- No I do not have to register the control at design time when loading from codebehind