我正在嘗試用兩個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在同一頁上?