母版页错误:该页面为一个或多个<asp:Content>(...)

时间:2019-09-17 14:10:52

标签: c# asp.net

我创建了一个母版页,然后创建了一个包含母版页的Web表单。在创建具有母版页的Web表单后,它给我以下错误:enter image description here

这是我的母版页(Principal.master)中的代码

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Principal.master.cs" Inherits="AgereWP.Principal" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .auto-style2 {
            width: 52px;
            height: 52px;
        }

        .auto-style3 {
            width: 384px;
            height: 111px;
        }
    </style>

</head>
<body>
    <form id="form1" runat="server">

        <h1 class="header">

            <img alt="" class="auto-style3" src="Imagens/Webp.net-resizeimage.png" /></h1>

        <div class="row">
            <div class="leftcolumn">
                <div class="card">
                    <h2>
                        <img src="Imagens/icons8-upload-24.png" />
                        Upload</h2>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </div>
                <div class="card">

                    <h2>
                        <img src="Imagens/icons8-download-24.png" />
                        Download</h2>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
                    </asp:ContentPlaceHolder>
                </div>
            </div>
        </div>
        <div class="footer">
            <h2>Rodape</h2>
        </div>
        <div>
        </div>
    </form>
</body>
</html>

这是带有主页面(default.aspx)的Web表单中的代码

<%@ Page Title="" Language="C#" MasterPageFile="~/Principal.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AgereWP.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

</asp:Content>

我尝试更改ContentPlaceHolderID,使用默认的ContentPlaceHolderID运行它,删除<!--->注释...并且无法弄清为什么会发生此错误。显然,它不允许我创建headContentPlaceHolder1以外的任何其他内容所有者,但我不明白为什么。

注意:我正在使用Visual Studio Community 2019

0 个答案:

没有答案