简体   繁体   English

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

[英]Master Page won't display its content on a Web Forms

I am creating a Web Forms project with a Master Page. 我正在创建一个具有母版页的Web窗体项目。 However, when I put a label on the master page (or any other control or html element) it does not display it on the web form. 但是,当我在母版页(或任何其他控件或html元素)上放置标签时,它不会在Web表单上显示它。 How can I fix this problem? 我该如何解决这个问题?

MasterPage: 母版页:

<%@ 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>

Web Form: 网络表格:

<%@ 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>

修复了此问题,只需要从内容占位符中删除控件即可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM