Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 12:05
    detroit
    0

    I get error trying to make home page child of master template : " Master directive not found"

    I've literally followed youtube tutorial by Warren Buckley and i simply cannot get it working without getting this error all the time while selecting master template for Homepage.

     

    Homepage template code:

     

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <umbraco:Item field="bodyText" runat="server"></umbraco:Item>

     

    Master template code:

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <html>
    <head>
        <title>
            <umbraco:Item field="pageName" runat="server"></umbraco:Item>
        </title>
    </head>
    <body>
        <h1>
            Welcome....
        </h1>

        <!-- Start of child template -->
        <asp:ContentPlaceHolder runat="server" id="MasterContentPlaceHolder" />
        <!-- End of child template -->

    </body>
    </html>
    </asp:Content>

     

    Is it just me not being able to follow a tutorial or is this buggy?

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 06, 2009 @ 12:19
    Peter Dijksterhuis
    0

    Hi,

    easiest way to create a child-template is simply to right-click on your master-template in the content-tree and then select 'Create new'.

    It will simply create a new template which has the mastertemplate allready set as mastertemplate.

    Also a default Contentplaceholder is added (which you need)

    Does this help you?

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 12:36
    detroit
    0

    Well i tried making master template at the begining

    so here's the order of creation:

     

    master template: code

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <html>
    <head>
        <title>
            <umbraco:Item field="pageName" runat="server"></umbraco:Item>
        </title>
    </head>
    <body>
        <h1>
            Welcome....
        </h1>

        <!-- Start of child template -->
        <umbraco:Item field="bodyText" runat="server"></umbraco:Item>
        <!-- End of child template -->

    </body>
    </html>
    </asp:Content>

     

    created child of this template named Home site with code:

    <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %>
    <umbraco:Item field="bodyText" runat="server"></umbraco:Item>

    THEN i created document type with allowed template Homesite, added a tab or two

    then created content and assigned this template Homesite to it

    but same problem occurs.

     

    So i've done it backward literally and some problem

     

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 12:36
    detroit
    0

    thanks for help tho:)

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 12:37
    detroit
    0

    The browser returns this error if this would help:

    Content controls have to be top-level controls in a content page or a nested master page that references a master page. body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Content controls have to be top-level controls in a content page or a nested master page that references a master page.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [HttpException (0x80004005): Content controls have to be top-level controls in a content page or a nested master page that references a master page.]
       System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8668328
       System.Web.UI.MasterPage.get_Master() +39
       System.Web.UI.MasterPage.ApplyMasterRecursive(MasterPage master, IList appliedMasterFilePaths) +18
       System.Web.UI.Page.ApplyMasterPage() +8699649
       System.Web.UI.Page.PerformPreInit() +45
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282
    

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Aug 06, 2009 @ 13:14
    Richard Soeteman
    0

    Hi,

    This is because you just write <umbraco:Item field="bodyText" runat="server"></umbraco:Item> in your child template. You have to put a content element arround it and in  the master put a ContentPlaceHolder tag. BTW if you follow the steps Peter suggested you can do that from the template editor. The buttons Insert Content area and content area placeholder really helpful.

    So for now it's the best thing to open the Master Template in Umbraco on the position where you want to insert the child template click the insert content area placeholder button(3th from the right) Enter the placeholder Id and click save

    Then open the child template, remove all but <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %> (Did you name the Master template Master)

    And click Insert Content area (2th button from the right). then select the placeholder id you've created in the master template. A new content area will be inserted in the template and in the content area you can display the bodytext using <umbraco:Item field="bodyText" runat="server"></umbraco:Item>.

    All this applies to ASP.NET masterpages in general. If you want to know more about masterpages check out http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx 

    Hope this helps you,

    Richard

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 06, 2009 @ 13:14
    Peter Dijksterhuis
    100

    Your master-template should look like:

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <html>
    <head>
        <title>
            <umbraco:Item field="pageName" runat="server"></umbraco:Item>
        </title>
    </head>
    <body>
        <h1>
            Welcome....
        </h1>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    </asp:Content>
    </body>
    </html> 

    The child-template then should look like this:

    <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
       <umbraco:Item runat="server" field="bodyText" />
    </asp:Content>

    Note the asp:Content in both files. The child-template must reference the masterpage

    HTH,

    Peter

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 13:38
    detroit
    0

    ook i came back noticing i was wrong :) i'll try what you two have suggested ty yet again

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 13:52
    detroit
    0

    we're getting somewhere, this seems to be the mistake when i followed either of your isntructions. Hopefully i'm not draining your spare time:)

     

    Parser Error body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

    Source Error:

    Line 1:  
    Line 2:  
    Line 3:  <html>
    Line 4:  <head>
    Line 5:     <title>


    Source File: /masterpages/Master.master    Line: 3

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 06, 2009 @ 14:15
    Peter Dijksterhuis
    0

    My bad!!! Sorry for that....

    Master:

     

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <html>
    <head>
    </head>
    <body>     
    <asp:ContentPlaceHolder ID="MasterContentPlaceHolder" runat="server"></asp:ContentPlaceHolder>
    </body>
    </html> 
    </asp:content>

     

     

    Child:

     

    <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="MasterContentPlaceHolder" runat="server">
    <umbraco:Item runat="server" field="bodyText" />
    </asp:Content>

     

     

  • detroit 12 posts 39 karma points
    Aug 06, 2009 @ 14:18
    detroit
    0

    you wouldnt believe me but i managed to fix it on my own, my day is gettin brighter by the minute:)

     

    Thanks both of you guys, what could i have done without you:)

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 06, 2009 @ 15:04
    Peter Dijksterhuis
    0

    Well done :)

  • Sarah Akhtar 2 posts 22 karma points
    Jan 16, 2012 @ 16:34
    Sarah Akhtar
    0

    Thank you very much for your answers , it really helped me too :)

Please Sign in or register to post replies

Write your reply to:

Draft