Yes. We can access master page controls from the content pages.
Below are the examples towards the same.
Example1:
TextBox tb = (TextBox)Master.FindControl("txtMaster");
tb.Text = "Something";
Example2:
ContentPlaceHolder
mpContentPlaceHolder;
TextBox mpTextBox;
mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if
(mpContentPlaceHolder != null)
{
mpTextBox = (TextBox)mpContentPlaceHolder.FindControl("TextBox1");
if
(mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
}
Example 3:
// Gets a
reference to a Label control that is not in a
//
ContentPlaceHolder control
Label mpLabel =
(Label)Master.FindControl("masterPageLabel");
if (mpLabel
!= null)
{
Label1.Text = "Master
page label = " + mpLabel.Text;
}