简体   繁体   English

母版页内容未显示在子级中

[英]Master page content not showing up in child

I know there is something I am missing on this 我知道这件事我想念的
But am unable to figure out that 但是我无法弄清楚
I have this master page: 我有这个母版页:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Mains.master.cs" Inherits="Sportsstop.Mains" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Sports Stop</title>
<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

N there is this Child page which should merge with the above master page: N子页面应与上面的母版页面合并:

<%@ Page Title="" Language="C#" MasterPageFile="~/Mains.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Sportsstop.Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" >

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>

Your textbox should be in child page, inside ContentPlaceholder1 . 您的文本框应位于子页面的ContentPlaceholder1 I think that the one in master page is ignored. 我认为主页中的那个被忽略了。

If you want to have TextBox in master page, it cannot be inside ContentPlaceholder 如果要在母版页中包含TextBox,则它不能位于ContentPlaceholder中

Think about placeholder as a place, where the content from child page gets injected 考虑将占位符作为一个位置,子页面中的内容将被注入该位置

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

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