在母版页"/MasterPage/Site.master"中找不到ContentPlaceHolder"HeadContent",请在内容页中验证内容控件的ContentPlaceHolderID属性. [英] Cannot find ContentPlaceHolder 'HeadContent' in the master page '/MasterPage/Site.master', verify content control's ContentPlaceHolderID attribute in the content page.

查看:140
本文介绍了在母版页"/MasterPage/Site.master"中找不到ContentPlaceHolder"HeadContent",请在内容页中验证内容控件的ContentPlaceHolderID属性.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人..

我是编程新手..

我在创建母版页时遇到了一些问题.


我收到错误消息为"

Dear All..

I am new to Programming..

I am facing Some Problem in the Creation Of the master Page.


I am Getting the Error as "

Cannot find ContentPlaceHolder 'HeadContent' in the master page '/MasterPage/Site.master', verify content control's ContentPlaceHolderID attribute in the content page."



请同样帮我.

以下是代码

< pre lang ="xml">& lt;%@ Master Language =& quot; C#& quot; AutoEventWireup =& quot; true& quot; CodeFile =& quot; Site.master.cs& quot; Inherits =&"Site&" %& gt;

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN&"& quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd& quot;
& lt; html xmlns =&"http://www.w3.org/1999/xhtml&"& gt;
& lt; head runat =& quot;服务器& quot;"
& lt; title& gt;使用母版页& lt;/title& gt;
& lt; asp:ContentPlaceHolder ID =&"head& quot; runat =& quot;服务器& gt;
& lt;/asp:ContentPlaceHolder& gt;
& lt//head& gt;
& lt; body& gt;
& lt; form id =& quot; form1& quot; runat =& quot;服务器& gt;
& lt; div& gt;
& lt; asp:ContentPlaceHolder id =& quot; ContentPlaceHolder1& quot; runat =& quot;服务器& gt;
< asp:Panel ID =&"Panel1& quot; runat =&服务器"宽度=&"100%& amp;". BackColor =&栗色&"& gt;
<表宽度=& quot; 100%& quot; style =&"height:0px&"& gt;
& lt; tr& gt;
& lt; td& gt;
& lt; a href =& quot; MainPage.aspx& quot;& gt;
< asp:图片ID =&图片1&" runat =&服务器" ImageUrl =& quot;〜/Images/mini_logo.gif& quot; /& gt;
& lt;/a& gt;
& lt//td& gt;
< td style =& quot;宽度:90%& quot;< br/> & lt; div style =& quot;文本对齐:居中"& gt;
& lt; h1& gt;
< asp:Label ID =& quot; Label1& quot; runat =&服务器" Style =&"font-weight:700;颜色:#FFFFFF; background-color:#9F0040& quot;
文字=& quot; ZAID QURESHI"& lt;/amp; lt;/asp:Label& gt;
& lt//h1& gt;
& lt//div& gt;
& lt//td& gt;
& lt; td& gt;
& lt; a href =& quot; MainPage.aspx& quot;& gt;
& lt; asp:图片ID =&图片2&" runat =&服务器" ImageUrl =& quot;〜/Images/pw_logo.gif& quot; /& gt;
& lt;/a& gt;
& lt//td& gt;
& lt//tr& gt;
& lt//table& gt;
& lt; table& gt;
& lt; tr& gt;
& lt; td& gt;
& lt; asp:Menu ID =& quot; Menu1& quot; runat =&服务器" BackColor =&#FFFBD6& quot; DynamicHorizo​​ntalOffset =&"2&"
Font-Names =& quot; Verdana& quot;字体大小=&"0.8em&". ForeColor =&#990000&" StaticSubMenuInde​​nt =&"10px&"& gt;
& lt; DynamicHoverStyle BackColor =& quot;#990000& quot; ForeColor =&白色". /& gt;
& lt; DynamicMenuItemStyle Horizo​​ntalPadding =& quot; 5px& quot; VerticalPadding =&"2px&" /& gt;
& lt; DynamicMenuStyle BackColor =& quot;#FFFBD6& quot; /& gt;
& lt; DynamicSelectedStyle BackColor =& quot;#FFCC66& quot; /& gt;
& lt;物品& gt;
& lt; asp:MenuItem Text =& quot; Home& quot;值=&首页& amp;" NavigateUrl =& quot; MainPage.aspx& quot;& lt;/asp:MenuItem& gt;
& lt;/Items& gt;
& lt; StaticHoverStyle BackColor =&#990000& quot; ForeColor =&白色". /& gt;
& lt; StaticMenuItemStyle Horizo​​ntalPadding =& quot; 5px& quot; VerticalPadding =&"2px&" /& gt;
& lt; StaticSelectedStyle BackColor =& quot;#FFCC66& quot; /& gt;
& lt;/asp:Menu& gt;
& lt//td& gt;
& lt; td& gt;
& lt; asp:Menu ID =& quot; Menu2& quot; runat =&服务器" BackColor =&#FFFBD6& quot; DynamicHorizo​​ntalOffset =&"2&"
Font-Names =& quot; Verdana& quot;字体大小=&"0.8em&". ForeColor =&#990000&" StaticSubMenuInde​​nt =&"10px&"& gt;
& lt; DynamicHoverStyle BackColor =& quot;#990000& quot; ForeColor =&白色". /& gt;
& lt; DynamicMenuItemStyle Horizo​​ntalPadding =& quot; 5px& quot; VerticalPadding =&"2px&" /& gt;
& lt; DynamicMenuStyle BackColor =& quot;#FFFBD6& quot; /& gt;
< DynamicSelectedStyle BackColor =& quot;#FFCC66& quot; /& gt;
& lt;物品& gt;
& lt; asp:MenuItem Text =&关于美国& quot;值=&关于美国" NavigateUrl =" About.aspx& quot;& lt;/asp:MenuItem& gt;
& lt;/Items& gt;
& lt; StaticHoverStyle BackColor =&#990000& quot; ForeColor =&白色". /& gt;
& lt; StaticMenuItemStyle Horizo​​ntalPadding =& quot; 5px& quot; VerticalPadding =&"2px&" /& gt;
& lt; StaticSelectedStyle BackColor =& quot;#FFCC66& quot; /& gt;
& lt;/asp:Menu& gt;
& lt//td& gt;
& lt//tr& gt;
& lt//table& gt;
& lt//asp:Panel& gt;
& lt;/asp:ContentPlaceHolder& gt;
& lt//div& gt;
& lt//form& gt;
& lt//body& gt;
& lt;/html& gt;</pre>


请帮我做同样的事情...


谢谢,



plz help me in the same.

The following is the code

<pre lang="xml">&lt;%@ Master Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Site.master.cs&quot; Inherits=&quot;Site&quot; %&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head runat=&quot;server&quot;&gt;
&lt;title&gt;Working With Master Page&lt;/title&gt;
&lt;asp:ContentPlaceHolder ID=&quot;head&quot; runat=&quot;server&quot;&gt;
&lt;/asp:ContentPlaceHolder&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
&lt;div&gt;
&lt;asp:ContentPlaceHolder id=&quot;ContentPlaceHolder1&quot; runat=&quot;server&quot;&gt;
&lt;asp:Panel ID=&quot;Panel1&quot; runat=&quot;server&quot; Width=&quot;100%&quot; BackColor=&quot;Maroon&quot;&gt;
&lt;table width=&quot;100%&quot; style=&quot;height: 0px&quot;&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;MainPage.aspx&quot;&gt;
&lt;asp:Image ID=&quot;Image1&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Images/mini_logo.gif&quot; /&gt;
&lt;/a&gt;
&lt;/td&gt;
&lt;td style=&quot;width: 90%&quot;&gt;
&lt;div style=&quot;text-align: center&quot;&gt;
&lt;h1&gt;
&lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Style=&quot;font-weight: 700; color: #FFFFFF; background-color: #9F0040&quot;
Text=&quot;ZAID QURESHI&quot;&gt;&lt;/asp:Label&gt;
&lt;/h1&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href=&quot;MainPage.aspx&quot;&gt;
&lt;asp:Image ID=&quot;Image2&quot; runat=&quot;server&quot; ImageUrl=&quot;~/Images/pw_logo.gif&quot; /&gt;
&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;asp:Menu ID=&quot;Menu1&quot; runat=&quot;server&quot; BackColor=&quot;#FFFBD6&quot; DynamicHorizontalOffset=&quot;2&quot;
Font-Names=&quot;Verdana&quot; Font-Size=&quot;0.8em&quot; ForeColor=&quot;#990000&quot; StaticSubMenuIndent=&quot;10px&quot;&gt;
&lt;DynamicHoverStyle BackColor=&quot;#990000&quot; ForeColor=&quot;White&quot; /&gt;
&lt;DynamicMenuItemStyle HorizontalPadding=&quot;5px&quot; VerticalPadding=&quot;2px&quot; /&gt;
&lt;DynamicMenuStyle BackColor=&quot;#FFFBD6&quot; /&gt;
&lt;DynamicSelectedStyle BackColor=&quot;#FFCC66&quot; /&gt;
&lt;Items&gt;
&lt;asp:MenuItem Text=&quot;Home&quot; Value=&quot;Home&quot; NavigateUrl=&quot;MainPage.aspx&quot;&gt;&lt;/asp:MenuItem&gt;
&lt;/Items&gt;
&lt;StaticHoverStyle BackColor=&quot;#990000&quot; ForeColor=&quot;White&quot; /&gt;
&lt;StaticMenuItemStyle HorizontalPadding=&quot;5px&quot; VerticalPadding=&quot;2px&quot; /&gt;
&lt;StaticSelectedStyle BackColor=&quot;#FFCC66&quot; /&gt;
&lt;/asp:Menu&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;asp:Menu ID=&quot;Menu2&quot; runat=&quot;server&quot; BackColor=&quot;#FFFBD6&quot; DynamicHorizontalOffset=&quot;2&quot;
Font-Names=&quot;Verdana&quot; Font-Size=&quot;0.8em&quot; ForeColor=&quot;#990000&quot; StaticSubMenuIndent=&quot;10px&quot;&gt;
&lt;DynamicHoverStyle BackColor=&quot;#990000&quot; ForeColor=&quot;White&quot; /&gt;
&lt;DynamicMenuItemStyle HorizontalPadding=&quot;5px&quot; VerticalPadding=&quot;2px&quot; /&gt;
&lt;DynamicMenuStyle BackColor=&quot;#FFFBD6&quot; /&gt;
&lt;DynamicSelectedStyle BackColor=&quot;#FFCC66&quot; /&gt;
&lt;Items&gt;
&lt;asp:MenuItem Text=&quot;About US&quot; Value=&quot;About US&quot; NavigateUrl=&quot;About.aspx&quot;&gt;&lt;/asp:MenuItem&gt;
&lt;/Items&gt;
&lt;StaticHoverStyle BackColor=&quot;#990000&quot; ForeColor=&quot;White&quot; /&gt;
&lt;StaticMenuItemStyle HorizontalPadding=&quot;5px&quot; VerticalPadding=&quot;2px&quot; /&gt;
&lt;StaticSelectedStyle BackColor=&quot;#FFCC66&quot; /&gt;
&lt;/asp:Menu&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/asp:Panel&gt;
&lt;/asp:ContentPlaceHolder&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>


Plz help me for the same...


Thanks,

推荐答案

请重命名aspx页面名称,因为MasterPage.aspx页面名称相同.

谢谢
Please rename your aspx page name as your MasterPage and .aspx page name are same.

Thanks


母版页将具有这样的内容占位符
Master pages will have content placeholders like this
 <asp:contentplaceholder id="head" runat="server" >
</asp:contentplaceholder><!--Take note of id='head' -->


使用母版页的Web内容页必须使用与母版页文件中指定的占位符ID相同的内容元素.


Web content pages those which use the master page must use content elements which has the same placeholder id specified in Master Page File.

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 
<!--ContentPlaceHolderID="head" is important-->
</asp:Content> 


在您的情况下,您使用的是ContentPlaceHolderID,而在这样的母版页中未指定.


In your case you are using a ContentPlaceHolderID which is not specified in master page like this.

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">  
</asp:Content> <!-- change  ContentPlaceHolderID="HeadContent" to ContentPlaceHolderID="head" --> 


这样可以修复错误.

希望对您有所帮助.


This will fix the error.

Hope it helps.


这篇关于在母版页"/MasterPage/Site.master"中找不到ContentPlaceHolder"HeadContent",请在内容页中验证内容控件的ContentPlaceHolderID属性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆