Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Recursive Search does not find correct controlRecursive Search does not find correct control
Previous
 
Next
New Post
4/19/2007 3:23 PM
 

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?

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Recursive Search does not find correct controlRecursive Search does not find correct control


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out