[英]Content controls have to be top-level controls in a content page or a nested master page that references a master page
[英]Content Page does not have content of Master Page
母版頁內容:
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<center>
<table border="0" cellspacing="0" style="border-collapse: collapse; border-top-width:0" bordercolor="red" width="970" bgcolor="#DDE1EE" cellpadding="0">
//all contents
</table>
</center>
</asp:ContentPlaceHolder>
</div>
</form>
內容頁:
<%@ Page Title="" Language="C#" MasterPageFile="~/CambridgeMaster.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Content>
在我的內容頁面中,我找不到任何母版頁內容。
它的工作方式略有不同。
它將“內容”頁面的內容注入到ContentPlaceholders中(有效替換其中的任何內容)。
您可以將ContentPlaceholder放置在要顯示內容頁面html的位置。
<center>
<table border="0" cellspacing="0" style="border-collapse: collapse; border-top-width:0" bordercolor="red" width="970" bgcolor="#DDE1EE" cellpadding="0">
//all contents
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</table>
</center>
請注意,我已將其放置在桌子內,並將其留空。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.