title: Access a content control in C# when using Master Pages
body: <p>Good day everyone,</p>
  
  <p>I am building a page in ASP.NET, and using Master Pages in the process.</p>
  
  <p>I have a Content Place Holder name "cphBody" in my Master Page, which will contain the body of each Page for which that Master Page is the Master Page.</p>
  
  <p>In the ASP.NET Web page, I have a Content tag (referencing "cphBody") which also contains some controls (buttons, Infragistics controls, etc.), and I want to access these controls in the CodeBehind file. However, I can't do that directly (this.myControl ...), since they are nested in the Content tag.</p>
  
  <p>I found a workaround with the FindControl method.</p>
  
  <pre><code>ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder) Master.FindControl("cphBody");
  ControlType myControl = (ControlType) contentPlaceHolder.FindControl("ControlName");
  </code></pre>
  
  <p>That works just fine. However, I am suspecting that it's not a very good design. Do you guys know a more elegant way to do so?</p>
  
  <p>Thank you!</p>
  
  <p>Guillaume Gervais. </p>