在母版页中包含的用户控件中引用文字时遇到一些问题。我正在使用以下页面进行测试(可能不必要地包含路径......):
~/_inc/header.ascx
~/master_pages/partner_header_footer.master
~/credit_check/test_page.aspx
header.ascx(相关内容)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="header.ascx.cs" Inherits="_inc_header" %>
<link type="text/css" rel="stylesheet" href="/css/header.css" />
<div id="header" class="content-header cf">
<div id="logo"></div><asp:Literal id="contentTitle" runat="server" Text="Customer Service" />
</div>
partner_header_footer.master(相关内容)
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="partner_header_footer.master.cs" Inherits="master_pages_partner" %>
<%@ Register Src="~/_inc/header.ascx" TagPrefix="uc1" TagName="header" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Wireless</title>
</head>
<body>
<form id="form1" runat="server">
<uc1:header runat="server" ID="header" />
<asp:ContentPlaceHolder id="Wireless" runat="server">
</asp:ContentPlaceHolder>
</form>
</body></html>
test_page.cs(相关内容)
protected void Page_Load(object sender, EventArgs e)
{
Literal mpLiteral = (Literal)Master.FindControl("contentTitle");
if (mpLiteral != null)
{
mpLiteral.Text = "Customer Service Home";
}
}
不知道我做错了什么,所以希望有人能指出我的方式的错误......