Content Web Form not permitting to add content
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;">
&l开发者_JAVA技巧t;/div>
</asp:Content>
I have following queries:
- The first
ContentPlaceHolder
ContentPlaceHolderID="head"
, what is it for? Both theContentPlaceHolder
s were automatically added when I added this nested master page to my project. - In the second
ContentPlaceHolder
withContentPlaceHolderID="ContentPlaceHolder1"
, I added twodiv
s. 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 ContentPlaceHolder
s. 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 ContentPlaceHolders
to the nested MasterPage
inside the Content
elements. eg
MasterPage 1:
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
Nested MasterPage:
<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;">
<-- Content on page goes inside this ContentPlaceHolder -->
<asp:ContentPlaceHolder ID="cphCmsDiv" runat="server">
</asp:ContentPlaceHolder>
</div>
</asp:Content>
Then add the corresponding Content
items to the page (they will be added automatically for new pages):
<asp:Content ID="Content3" ContentPlaceHolderID="cphCmsDiv" runat="server">
</asp:Content>
精彩评论