Adding a UserControl within another UserControl in Sharepoint 2007
- by DougJones
I am using WSPBuilder to create and deploy my web part from a user control, as shown here. This works perfectly well, but I have added another user control to the project. I am adding it in page_init by going the
Page.LoadControl("~/_controltemplates/MyControl.ascx");
route.
It builds successfully, but after adding it to the page, I get
The referenced file '/MyControl.ascx' is not allowed on this page.
This control is in the ControlTemplates folder in the hive. In the web.config for this sharepoint 2007 site, all items within _controltemplates are listed as safe, as shown here
<SafeControl Src="~/_controltemplates/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />
How do I get the ascx file to be allowed on the page and get this webpart to display successfully?