title: Nested ASCX controls' properties not accessible at Page-level
body: <p>Note, before marking as duplicate - <a href="https://stackoverflow.com/questions/6757911/using-teleriks-radajaxmanager-with-nested-ascx-controls">similar</a> questions have been asked before, but all reference specific third-party libraries with solutions to match.  This question relates solely to the native ASP.Net framework, and I am looking for an explanation of <em>why</em> this behaviour occurs in addition to the best solution.</p>
  
  <p>I have a Page structure like this:</p>
  
  <p><img src="https://i.stack.imgur.com/wypSR.png" alt="enter image description here"></p>
  
  <p>Within ControlA, I expose the textbox as a <code>Public Property</code> so that I can access it at page-level.  So, at page-level, this works perfectly:</p>
  
  <pre><code>Trace.Warn(ControlA.TextBoxA.Text) ' prints "Control A Text Box"
  </code></pre>
  
  <p>However, exposing ControlB's textbox as a public property in the same manner does not allow it to be available at page-level.  This code at page-level...</p>
  
  <pre><code>Trace.Warn(ControlA.NestedControlB.TextBoxB.Text)
  </code></pre>
  
  <p>...fails with this error:</p>
  
  <blockquote>
    <p>BC30652: Reference required to assembly 'App_Web_3jwc5ppn</p>
  </blockquote>
  
  <p>The same is also true of any methods that are placed in ControlB that need to be accessible at page-level.
  Clicking the "Add Reference" link achieves nothing, and moreso, the assembly title changes <em>every</em> time the project is rebuilt.</p>
  
  <h2>A solution, but is it the best for complex controls?</h2>
  
  <p>I can bubble up the properties by declaring the ControlB textbox as a property in ControlA, like this:</p>
  
  <pre><code>Public ReadOnly Property NestedControlBTextBox As TextBox
      Get
          Return ControlB.TextBoxB()
      End Get
  End Property
  </code></pre>
  
  <p>This allows the nested textbox to be accessible at page-level with this:</p>
  
  <pre><code>Trace.Warn(ControlA.NestedControlBTextBox.Text) ' prints "Control B Text Box"
  </code></pre>
  
  <p>But is this the best/correct approach?  It seems like an awful lot of work to bubble up <em>every</em> property and/or event up N levels of hierarchy.  Obviously my real ASCX controls are way more complex than this.</p>
  
  <p>I have <a href="https://onedrive.live.com/redir?resid=2A562CFE564E2506!598&amp;authkey=!AB8tU6oryTUDup8&amp;ithint=file%2Czip" rel="nofollow noreferrer">enclosed the solution</a> in case anyone wants to illustrate a better approach.</p>