2

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!!

1 Answer 1

5

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>
1
  • Thank you, much appreciated! I feel like I tried that before but perhaps I was programming too late at night.
    – holaworld
    Jun 21, 2013 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.