Accessing Child Controls of a Template Server Control

I've created a templated control that has a property called ContentTemplate which is of type ITemplate.  The control works great with the exception of I now have to interact with the child controls via the FindControl method.


<test:MyControl ID="testControl" runat="server">
    <asp:Label ID="testLabel" runat="server" />

 In order to interact with the child label, testLabel, I now need to do something like this:

Dim lbl As Label = CType(testControl.FindControl("testLabel"), Label)
lbl.Text = "Something new!"

Is there a way to avoid this?  The reason I think this is even possible is that the UpdatePanel of AJAX has a ContentTemplate property that still allows a developer to interact with the objects they create within that tag.


2/4/2008 7:43:41 PM 3498 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 33