title: How To retrieve a control in a Master Page from Content Page
body: <p>When I asked recently a question about how <strong>To retrieve a control in a Master Page from Content Page</strong>.
  Many peoples suggest me to use this code from my Content Page:</p>
  
  <pre><code>    Label lbl = this.Master.Page.FindControl("uxLabel") as Label;
  //Note any server controls defined in the master page could be not be accessible even after a cast is performed, because they could be marked as protected
  </code></pre>
  
  <p>This approach certainly works, I also realize that is available a strongly-typed solution  that doesn't involve casting the Master property.</p>
  
  <p>In the Master Page place:</p>
  
  <pre><code>public Label HeaderLabel
  {
      get { return uxLabel; }
  }
  </code></pre>
  
  <p>Using a MasterType in the Content Page:</p>
  
  <pre><code>    &lt;%@ MasterType VirtualPath="~/Templates/WebsiteMasterPage.master" %&gt;
  </code></pre>
  
  <p>Now it is pretty easy find the control from the Content Page:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      this.Master.HeaderLabel.Text = "Any Text here!";
  }
  </code></pre>
  
  <p>I would like to know:</p>
  
  <ul>
  <li>what do you think about this
  approach?
  any other solution?</li>
  </ul>
  
  <p>Thanks for your time</p>