Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 "
CSS
Cannot find ContentPlaceHolder 'HeadContent' in the master page '/MasterPage/Site.master', verify content control's ContentPlaceHolderID attribute in the content page."


plz help me in the same.

The following is the code

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


Plz help me for the same...


Thanks,

What I have tried:

Plz help me for the same...


Thanks,
Posted
Updated 19-Nov-21 23:52pm
v2
Comments
Himanshu Yadav 22-Oct-12 3:46am    
when u r getting this error

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

Thanks
 
Share this answer
 
Comments
[no name] 22-Oct-12 5:47am    
my 5
Master pages will have content placeholders like this
ASP.NET
 <asp:contentplaceholder id="head" runat="server" >
</asp:contentplaceholder><!--Take note of id='head' -->

Web content pages those which use the master page must use content elements which has the same placeholder id specified in Master Page File.
XML
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 
<!--ContentPlaceHolderID="head" is important-->
</asp:Content> 

In your case you are using a ContentPlaceHolderID which is not specified in master page like this.
XML
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">  
</asp:Content> <!-- change  ContentPlaceHolderID="HeadContent" to ContentPlaceHolderID="head" --> 

This will fix the error.

Hope it helps.
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900