title: ASP.NET Custom Control - Naming Container
body: <p>I have 2 user controls, I is used as a container for the other:</p>
  
  <pre><code>&lt;mc:Container runat="server" ID="container"&gt;
     &lt;mc:MyControl runat="server" ID="test"&gt;
  &lt;/mc:Container&gt;
  </code></pre>
  
  <p>The mc Container has a default inner property called content which is a collection of <code>MyControls</code>.</p>
  
  <p>The markup above is inside a <code>FormView</code>, and when I call <code>FindControl</code> on the formview it can find the container, but it cannot find the test.</p>
  
  <p>How can I make the container control not create a new Naming container?</p>
  
  <p>EDIT__</p>
  
  <p>When not in a <code>FormView</code>, the inner control's IDs do show up as part of the page in the designer, so there it is working. </p>
  
  <p>EDIT__</p>
  
  <p>Here is my vb for the container:</p>
  
  <pre><code>&lt;ParseChildren(True, "Content")&gt; _
  Partial Public Class ctrFormContainer
      Inherits System.Web.UI.UserControl
  
      Private _content As FormControlCollection
      &lt;PersistenceMode(PersistenceMode.InnerDefaultProperty), _
      TemplateInstance(TemplateInstance.Single)&gt; _
      Public Property Content() As FormControlCollection
          Get
              Return _content
          End Get
          Set(ByVal value As FormControlCollection)
              _content = value
          End Set
      End Property
  
      Protected Overrides Sub CreateChildControls()
          If _content IsNot Nothing Then
              ctrChildren.Controls.Clear()
              For Each i As FormControl In _content
                  ctrChildren.Controls.Add(i)
              Next
          End If
          MyBase.CreateChildControls()
  
      End Sub
  
      Public Overrides Function FindControl(ByVal id As String) As System.Web.UI.Control
          Return MyBase.FindControl(id)
      End Function
  
      Public Class FormControlCollection
          Inherits List(Of FormControl)
      End Class
  End Class
  </code></pre>