umbraco template error: "Content controls have to be top-level controls in a content page or a nested master page that references a master page."

14,771

Your master template (A-BTestingItem.master) is missing a Content tag, that should wrap the ContentPlaceHolder tag, like so:

<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderId="ContentPlaceHolderDefault" runat="server">
    <asp:ContentPlaceHolder Id="MainContent" runat="server">
        <umbraco:Macro Alias="Redirector" runat="server" />
    </asp:ContentPlaceHolder>
</asp:Content>
Share:
14,771
holaworld
Author by

holaworld

Updated on June 13, 2022

Comments

  • holaworld
    holaworld almost 2 years

    I've come across an issue which I can't seem to explain. I've setup a master and 2 child templates in Umbraco and I get the following error:

    Content controls have to be top-level controls in a content page or a nested master page that references a master page.

    I first checked to make sure my master-child template code and it appears to be fine. I deleted the templates in question, re-created new templates, and even played with the ID names but nothing changed.

    Here's the Master template (A-BTestingItem.master) code:

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %> 
    <asp:ContentPlaceHolder Id="MainContent" runat="server">
    <umbraco:Macro Alias="Redirector" runat="server" />
    </asp:ContentPlaceHolder>
    

    Here's the first child template code for Template A:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/A-BTestingItem.master" AutoEventWireup="true" %>
    
    <asp:content ContentPlaceHolderId="MainContent" runat="server">
    Hello from Template A
    </asp:content>
    

    Here's the second child template code for Template B:

    <%@ Master Language="C#" MasterPageFile="~/masterpages/A-BTestingItem.master" AutoEventWireup="true" %>
    
    <asp:content ContentPlaceHolderId="MainContent" runat="server">
    Hello from Template B
    </asp:content>
    

    I assigned Template A and B to the document type. When I published the document and viewed it, I received the error above. I'm stumped. I've read in another post that this might be symptoms of a virus but doesn't seem the case currently. Any help is much appreciated!!