Master Page More有多个内容

时间:2012-03-12 03:11:16

标签: c# asp.net master-pages

刚才我创建了母版页时它给了我这个错误。该页面具有一个或多个与内容占位符不对应的asp内容。 我的母版有什么问题?这是我的母版页代码。谢谢。

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"   
 Inherits="MasterPage" %>

 <!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>Master</title>
 <asp:ContentPlaceHolder id="head" runat="server">
 </asp:ContentPlaceHolder>
 <style type="text/css">
    .style1
    {
        height: 63px;
    }
    .style3
    {
        height: 101px;
        font-size: xx-large;
        font-weight: 700;
        font-family: Tahoma;
        text-align: center;
        color: #FFFFFF;
    }
    .style6
    {
        width: 146px;
        height: 592px;
    }
    .style7
    {
        width: 897px;
        height: 592px;
    }
    .style8
    {
        height: 592px;
    }
    .style9
    {
        font-size: small;
        height: 101px;
        border-left-color: #808080;
        border-right-color: #C0C0C0;
        border-top-color: #808080;
        border-bottom-color: #C0C0C0;
        background-color: #996633;
    }
    </style>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <table style="width: 100%; height: 623px; margin-bottom: 0px;">
        <tr>
            <td bgcolor="#996633" class="style3" colspan="3">
                Malaysia Car Booking System<br />
                <span class="style9">Your satisfaction is our Priority</span></td>
        </tr>
        <tr>
            <td bgcolor="#CC6600" class="style6">
            </td>
            <td bgcolor="#FF9900" class="style7" style="vertical-align: top">
                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
            </td>
            <td bgcolor="#CC6600" class="style8">
            </td>
        </tr>
        <tr>
            <td bgcolor="#996633" class="style1" colspan="3">
            </td>
        </tr>
    </table>
      </div>
     </form>
     </body>
     </html>

4 个答案:

答案 0 :(得分:3)

您的内容页面中的Content标记在母版页中没有相应的ContentPlaceHolder标记,这有什么问题。

母版页中唯一的ContentPlaceHolder标记位于head标记中。在body标签中没有任何内容是非常罕见的,因为它很难从内容页面引入任何正文内容。您的身体中有一个PlaceHolder标记,您可能想要成为ContentPlaceHolder标记吗?

答案 1 :(得分:2)

您的网页似乎有<asp:content>个标记,与您在MasterPage中的<asp:ContentPlaceHolder>控件不对应。

对于此类解决方案,母版页永远不会支持<!-- -->

格式的评论

这可能会导致您的错误。

答案 2 :(得分:0)

当我创建一个非常简单的母版页并让visual studio基于该母版页创建一个普通页面时,我遇到了同样的错误。运行网站后,错误消息消失。似乎错误消息基于旧的母版页,并且Visual Studio仅在网站实际运行时才使用已更改的母版页进行验证。奇怪: - (

答案 3 :(得分:0)

在解决问题的大部分时间内,您需要在标题标记中加入runat = "server"

相关问题