可以,假设Master有一个Label控件,代码如下:
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
在Child的cs文件中可以这样写:
protected void Page_Load(object sender, EventArgs e)
{
Label label = new Label();
label = (Label)Page.Master.FindControl("Label1");
label.Text = "111";
}
{
Label label = new Label();
label = (Label)Page.Master.FindControl("Label1");
label.Text = "111";
}