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.0finding a control in a DNN modulefinding a control in a DNN module
Previous
 
Next
New Post
11/27/2007 8:56 AM
 

Thanks for the help but no success with that.

If I place my lable in a panel and outside the datalist it works perfectly.
When the label is placed inside the itemtemplate of the datalist it doesn't work.

So now I need to know how to change the text of a label within a datalist with a press of a button.

Hope someone knows the solution to this.

 

 
New Post
11/27/2007 11:22 AM
Accepted Answer 

Not sure why it won't outside the list, but in the list you likely need to do a recursive search.  Also you will need to be able to collect more than one label.  Here's a snippet of code where I am doing something similar.  -

        Protected Function FindInputControls(ByVal objContainer As System.Web.UI.Control) As ArrayList
 
            Dim objChildControl As System.Web.UI.Control
            Dim foundControls As New ArrayList
 
            For Each objChildControl In objContainer.Controls
 
                ' check if control is a input control
                If TypeOf objChildControl Is StratagemApp.UI.Controls.Input Then
                    foundControls.Add(objChildControl)
                End If
 
                If objChildControl.HasControls Then
                    Dim objFoundControls As ArrayList = FindInputControls(objChildControl)
 
                    If Not (objFoundControls Is Nothing) Then
                        Dim c As System.Web.UI.Control
                        For Each c In objFoundControls
                            foundControls.Add(c)
                        Next
                    End If
                End If
            Next
            Return foundControls

        End Function

You'll need to replace the "input" object with a "label".  Also if you have more than one label you'll need to check the ID.  When it returns, the arraylist will hopfully contain the labels you're seeking.

Hope it helps....

 
New Post
11/27/2007 4:21 PM
 

Yes ofcourse I need to iterate through the controls. And I will probably have to generate the ID's of the labels that are in the datalist. like <asp:label ID="<%=generateMyOwnID %>" ... etc and then iterate through the id's and when the label id contains a string that I have put in the generated ID for the label then I will probably have my label(s).

I am going to try that tomorrow. Thanks alot for the help!

And it works outside the list now, but only if I put an asp:panel around it.


I will set this topic as answered as I know what I was doing wrong. If any problems occur with the iteration I will post on the asp.net forum.
Thanks again!

 
New Post
11/27/2007 5:25 PM
 

Like in previos post I use recursive functions for situations this. I did wrote function (a long time ago :-) you can use it for your case. I think it fit perfectly for your needs. Input module control as root (but this can be page control also):

      ''' <summary>
        ''' Return control or any child with specified id .
        ''' </summary>
        ''' <param name="Root">ControlID or list of possible controlIDs separated with semicolon.</param>
        ''' <param name="Id"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function FindControl(ByVal Root As Control, ByVal Id As String) As Control
            Dim ids() As String = Split(Id, ";")
            Dim currentId As String
            For Each currentId In ids
                If LCase(Root.ID) = LCase(currentId) Then
                    Return Root
                End If
            Next
            Dim Ctl As Control
            For Each Ctl In Root.Controls
                Dim FoundCtl As Control = FindControl(Ctl, Id)
                If Not FoundCtl Is Nothing Then
                    Return FoundCtl
                End If
            Next
            Return Nothing
        End Function

 
New Post
11/28/2007 3:07 AM
 

Thats very usefull aswell pril. Thanks alot.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0finding a control in a DNN modulefinding a control in a DNN module


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