Anyone,
I am writing a function in hopes to solve a problem I posted about earlier. My skin has 2 panes LeftPane and ContentPane. They are defined as TD elements in the skin.ascx file and are set runat="server". According to my understanding of ASP.NET, they should have the server-side controls of LeftPane and ContentPane respectively, but may have any arbitrary clientid. Therefore I wrote a function to recursivly search for a htmlcontrol from a starting point matching a server-side id. this is a basic function:
Private Function FindHtmlControlRecursive(ByVal oControl As Control, ByVal ID As String) As Control
If (oControl.ID = ID) And (TypeOf oControl Is HtmlControl) Then
Return CType(oControl, HtmlControl)
ElseIf oControl.HasControls Then
Dim rControl As Control
Dim tControl As Control
For Each rControl In oControl.Controls
tControl = FindHtmlControlRecursive(rControl, ID)
If Not tControl Is Nothing Then
If TypeOf tControl Is HtmlControl Then
Return CType(tControl, HtmlControl)
Else : Return Nothing
End If
End If
Next
Else
Return Nothing
End If
End Function
I call it like:
Dim parent As Control = FindHtmlControlRecursive(Me.Page, "ContentPane"), which I would assume would search from the top page, itterate through its controls until it finds a control with ContentPane as the server-side ID and return a reference to that control.
This is where my understanding goes right out the window. It does return a reference to a control, and looking at the properties, the ClientID = dnn_ctr414_ContentPane, the ID is ContentPane, SkinID = "", and UniqueID = dnn$ctr414$ContentPane.
When I let the program go, it tries to populate the control with information, however the reference to the control is a Container in my LeftPane, not the ContentPane itself.
How can more than 1 control have the same server-side ID?
Also, If I look at the source of the rendered page, the ContentPane actually has a ClientId of dnn_ContentPane, since .NET chooses the name of the ClientID, I don't think I can guarantee the clientid will always be ContentPane, right?
This is just confusing the heck out of me. How can I find a reference to a control on a page if searching by a known server-side ID will not work?
Can someone please elaborate on this for me?