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.
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
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>.
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>
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?
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?
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
thanks for help tho:)
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:
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
Your master-template should look like:
The child-template then should look like this:
<umbraco:Item runat="server" field="bodyText" />
Note the asp:Content in both files. The child-template must reference the masterpage
HTH,
Peter
ook i came back noticing i was wrong :) i'll try what you two have suggested ty yet again
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
My bad!!! Sorry for that....
Master:
<body>
Child:
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:)
Well done :)
Thank you very much for your answers , it really helped me too :)
is working on a reply...