我正在尝试用两个ContentPlaceHolder部分创建一个Main.master页面。 当我加载默认页面,它只呈现ContentPlaceHolder1,我不得不实际加载Second.aspx看到第二个ContentPlaceHolder。为什么?从单独文件加载ContentPlaceHolders
在我Main.master我:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</div>
</body>
</html>
此外,我已经创建了两个附加页的Default.aspx和Second.aspx:
Detault:
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
HOW HOW HOW HOW
</asp:Content>
其他页面
Second:
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Second.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
COW COW COW COW
</asp:Content>
它只渲染第一个PlaceHolder,我怎样才能拥有单独的内容文件并且同时具有渲染d在同一页上?