gpt4 book ai didi

c# - 内容控件必须是内容页或引用母版页的嵌套母版页中的顶级控件

转载 作者:太空狗 更新时间:2023-10-29 20:03:14 25 4
gpt4 key购买 nike

我想使用嵌套母版页,所以我创建了以下母版页:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="test.master.cs" Inherits="DocumentFlowUI.test" MasterPageFile="~/MasterPage2.master" %>

<!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></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

然后我创建了以下页面来使用该母版页:

<%@ Page Title="" Language="C#" MasterPageFile="~/test.Master" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="DocumentFlowUI.WebForm4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Content>

我收到以下错误:

Content controls have to be top-level controls in a content page or a nested master page that references a master page

最佳答案

嵌套母版页中的 HTML 代码必须用带有来自“母版”母版页的 contentplaceholderid 的 asp:content-tag 包裹。

关于c# - 内容控件必须是内容页或引用母版页的嵌套母版页中的顶级控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13745449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com