Programatically loading user controls
Posted
by PhilSando
on Geeks with Blogs
See other posts from Geeks with Blogs
or by PhilSando
Published on Thu, 27 May 2010 08:41:48 GMT
Indexed on
2010/05/27
10:02 UTC
Read the original article
Hit count: 262
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!
© Geeks with Blogs or respective owner