母版页不会在Web窗体上显示其内容

时间:2019-08-26 10:52:21

标签: c# webforms master-pages

我正在创建一个具有母版页的Web窗体项目。但是,当我在母版页(或任何其他控件或html元素)上放置标签时,它不会在Web表单上显示它。我该如何解决这个问题?

母版页:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="RWA.MasterPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form" runat="server">
<div>
<asp:ContentPlaceHolder ID="MasterPagePlaceHolder" runat="server">
<asp:Label ID="NameLabel" runat="server" Text="Label"></asp:Label> 
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

网络表单:

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

1 个答案:

答案 0 :(得分:0)

修复它,只需要从内容占位符中删除控件