Problem when adding ascx user control in the MasterPage: Parser Error Message: The referenced file ... is not allowed on this page.

Hello,
I have to maintain a SharePoint 2010 project, in which a TopNavigation User Control for SiteCollection is registered in the MasterPage in this way:
<%@ Register TagPrefix="ABC" TagName="TopNavigation" src="~/_layouts/ABCApplication/MainSite/Navigation/TopNavigation.ascx" %>
<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
                                    <ABC:TopNavigation ID="TopNavi" XMLDataLocation="/_layouts/ABCApplicatopm/MainSite/TopNavigation.xml" IsRoot="true"
runat="server" />
</asp:ContentPlaceHolder>
</asp:ContentPlaceHolder>
When I deploy the SiteCollection, the TopNavigation user control is working correctly. Unfortunately when i modify the masterpage over SharePoint Designer, the following error message comes allways, regardless of the art of changes i did in the MAsterPage
( even if I open the MasterPage, add an space and do save/close the MasterPage).
"Problem when adding user control in my custom master page, Parser Error Message: The referenced file '/_layouts/Navigation/TopNavigation.ascx' is not allowed on this page."
Any ideas?

Hi Simon,
 When we use UserControl in SharePoint Page or MasterPage, and the UserControl is kept in any folder other than ControlTemplates, we will got the error. Here is an article about this issue and provided the solution:
http://sharepoint-tina.blogspot.com/2009/07/referenced-file-pathxyzascx-is-not.html 
The solution can also be used in SharePoint 2010.
Qiao Wei
TechNet Community Support

Similar Messages

Maybe you are looking for