Adding a UserControl within another UserControl in Sharepoint 2007
Posted
by DougJones
on Stack Overflow
See other posts from Stack Overflow
or by DougJones
Published on 2010-05-11T19:29:42Z
Indexed on
2010/05/11
19:34 UTC
Read the original article
Hit count: 914
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?
© Stack Overflow or respective owner