title: How do I access controls from the parent page from within an ASP.NET User Control?
body: <p>I have an ASP.NET Web Forms page <code>childPage.aspx</code> with <code>masterPage.aspx</code> as the master page. The <code>childPage.aspx</code> has a user control (<code>userControl.ascx</code>) control defined on it. Now, I am trying to access the controls on <code>childPage.aspx</code> from within the user control. I have tried a handful of different approaches:</p>
  
  <pre class="lang-cs prettyprint-override"><code>HtmlContainerControl ProductMenu = (HtmlContainerControl)Page.FindControl("ProductMenu");
  
  HtmlContainerControl ProductMenu = (HtmlContainerControl)this.Page.FindControl("ProductMenu");
  
  HtmlContainerControl ProductMenu = (HtmlContainerControl)Parent.FindControl("ProductMenu");
  
  HtmlContainerControl ProductMenu = (HtmlContainerControl)this.Parent.parent.FindControl("ContaintHolder").FindControl("ProductMenu")
  </code></pre>
  
  <p>In above code, <code>ProductMenu</code> is the <code>id</code> of the <code>&lt;div runat="server" /&gt;</code> on <code>childPage.aspx</code>. Now, I am trying to access it from within my user control, but that fails to return the <code>div</code>. </p>
  
  <p>Please help me out. How should I do this? Thanks in advance.</p>