【问题标题】:Master Page More has more than one contentMaster Page More 包含多个内容
【发布时间】:2014-06-09 17:47:38
【问题描述】:

刚刚创建我的母版页时,它给了我这个错误。该页面包含一个或多个与asp 内容占位符不对应的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>

【问题讨论】:

  • 您阅读了邮件吗?你不明白什么?

标签: c# asp.net master-pages


【解决方案1】:

问题是您的内容页中有一个Content 标记,而母版页中没有相应的ContentPlaceHolder 标记。

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

【讨论】:

    【解决方案2】:

    您的页面似乎包含 &lt;asp:content&gt; 标记,这些标记与 MasterPage 中的 &lt;asp:ContentPlaceHolder&gt; 控件不对应。

    对于这种类型的解决方案,母版页从不支持 &lt;!-- --&gt; 格式的 cmets

    这可能会导致您的错误。

    【讨论】:

    • +1...谢谢你的人..!我从来不知道。解决了我的问题!
    【解决方案3】:

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

    【讨论】:

      【解决方案4】:

      您需要在 title 标记中包含runat = "server" 大部分时间它可以解决问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-16
        • 1970-01-01
        相关资源
        最近更新 更多