This is the code of a nested master page in my project:
<%@ Master Language="C#" MasterPageFile="~/Presentation_Layer/Pages/home.Master" AutoEventWireup="true" CodeBehind="cmsNestedMasterPage.master.cs" Inherits="livetest.Presentation_Layer.Pages.cmsNestedMasterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="divMenuSideBarLeft" class="MainSideBar1Div" style="top: 2px"
title="LiveTest CMS Menu">
</div>
<div id="divCmsContent" class="MainContentDiv" title="divCmsContent"
style="background-color: ButtonFace; width: 791px; left: 203px; position:relative; top: -602px;">
</div>
</asp:Content>
I have following queries:
- The first
ContentPlaceHolderContentPlaceHolderID="head", what is it for? Both theContentPlaceHolders were automatically added when I added this nested master page to my project. - In the second
ContentPlaceHolderwithContentPlaceHolderID="ContentPlaceHolder1", I added twodivs. One is to display a side-bar on the left and the other is where I am going to show forms for entry. The problem is that when I added a new Web Content Form and linked it to this master page, it has only one pre-written line:
<%@ Page Title="" Language="C#"
MasterPageFile="~/Presentation_Layer/Pages/cmsNestedMasterPage.master"
AutoEventWireup="true" CodeBehind="BookEntry.aspx.cs"
Inherits="livetest.Presentation_Layer.Pages.CMS.BookEntry" %>
The code is not showing any ContentPlaceHolders. Even if I try to add one, it gives error:
The page has one or more
<asp:Content>controls that do not correspond with<asp:ContentPlaceHolder>controls in the Master page.
How to rectify this error?
You need to add
ContentPlaceHoldersto the nestedMasterPageinside theContentelements. egMasterPage 1:
Nested MasterPage:
Then add the corresponding
Contentitems to the page (they will be added automatically for new pages):