Hi,
You do not directly access a component of the main page. Its assignatury is of the
protected type.
For you access the label component, I suggest that you use public properties in your master page.
HTML code in your master page
<div>
<asp:Label ID="lblSubHd" runat="server" Text="Um Texto"></asp:Label>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
To access the component, here, the code.
Code-behind to master page
public Label MyLabel
{
get
{
return this.lblSubHd;
}
}
Code-behind to child page
Label mylabelchild = this.Master.MyLabel;
To access the text property of the label component, here, the code.
Code-behind to master page
public string ValueLabel
{
get
{
return this.lblMyLabel.Text;
}
}
Code-behind to child page
this.MylabelChild.Text = this.Master.ValueLabel;
IMPORTANT! For you use the solution above your child page need to have the master page in asp tag.
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Main.Master" CodeBehind="child_page.aspx.cs" Inherits="aplicacao.child_page" %>
<%@ MasterType VirtualPath="~/Main.Master" %>