I have 2 user controls, I is used as a container for the other:
<mc:Container runat="server" ID="container">
<mc:MyControl runat="server" ID="test">
</mc:Container>
The mc Container has a default inner property called content which is a collection of MyControls
.
The markup above is inside a FormView
, and when I call FindControl
on the formview it can find the container, but it cannot find the test.
How can I make the container control not create a new Naming container?
EDIT__
When not in a FormView
, the inner control's IDs do show up as part of the page in the designer, so there it is working.
EDIT__
Here is my vb for the container:
<ParseChildren(True, "Content")> _
Partial Public Class ctrFormContainer
Inherits System.Web.UI.UserControl
Private _content As FormControlCollection
<PersistenceMode(PersistenceMode.InnerDefaultProperty), _
TemplateInstance(TemplateInstance.Single)> _
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