Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:40:47+00:00 2026-05-25T16:40:47+00:00

I have a dynamic webpage that loads a user control multiple times, including loading

  • 0

I have a dynamic webpage that loads a user control multiple times, including loading the user control within itself as many times as needed. Within the user control there are four controls: Title Label, Repeater, Placeholder and within Repeater a AjaxControlToolkit Rating control.

The structure can look like the following:

Webpage
  Placeholder
    UserControl (repeater hidden, no data)
      Placeholder - [UserControl]
        UserControl
          Repeater
            RepeaterItem - [RatingControl]
            RepeaterItem - [RatingControl]
          Placeholder - [UserControl]
            UserControl (placeholder hidden, no data)
              Repeater
                RepeaterItem - [RatingControl]
                RepeaterItem - [RatingControl]
    UserControl
      Repeater
        RepeaterItem - [RatingControl]
        RepeaterItem - [RatingControl]
      Placeholder - [UserControl]
        UserControl (placeholder hidden, no data)          
          Repeater
            RepeaterItem - [RatingControl]

Here is my recursive method:

Protected Sub Get_Ratings(ByVal ctl As Control, ByVal grouptotal As Integer)
    If TypeOf ctl Is PerformanceEvaluationSubcontractorControl Then
        Dim pesctl As Control
        For Each pesctl In ctl.Controls
            If TypeOf pesctl Is PerformanceEvaluationSubcontractorControl Then
                Me.Get_Ratings(pesctl, grouptotal)
            ElseIf pesctl.Controls.Count > 0 Then
                Dim spesctl As Control
                For Each spesctl In pesctl.Controls
                    If TypeOf spesctl Is Repeater Then
                        Dim rptctl As Control
                        For Each rptctl In spesctl.Controls
                            Me.Get_Ratings(pesctl, grouptotal)
                        Next
                    End If
                    If TypeOf spesctl Is PlaceHolder Then
                        Dim plhctl As Control
                        For Each plhctl In spesctl.Controls
                            Me.Get_Ratings(plhctl, grouptotal)
                        Next
                    End If
                Next
            ElseIf TypeOf pesctl Is AjaxControlToolkit.Rating Then
                Dim ajrating As AjaxControlToolkit.Rating = pesctl
                grouptotal = grouptotal + ajrating.CurrentRating
            End If
        Next
    ElseIf ctl.Controls.Count > 0 Then
        Dim sctl As Control
        For Each sctl In ctl.Controls
            Me.Get_Ratings(sctl, grouptotal)
        Next
    End If
End Sub

My question is, how do I efficiently loop through this type of structure to find the rating controls?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:40:47+00:00Added an answer on May 25, 2026 at 4:40 pm

    Sorry, my VB.NET isn’t all that great, but wouldn’t a recursive function look similar to:

    Protected Function GetRatings(ByVal control As Control) As IEnumerable(Of AjaxControlToolkit.Rating)
      If (control.Controls.Count > 0) Then
        Dim result As New List(Of AjaxControlToolkit.Rating)()
    
        For Each child In Control.Controls
          Dim rating As AjaxControlToolkit.Rating = child As AjaxControlToolkit.Rating
          If Not (rating Is Nothing) Then
            result.Add(rating)
          Else
            result.AddRange(GetRatings(child))
          End If  
        Next
    
        Return result
      Else
        Return Enumerable.Empty(Of AjaxControlToolkit.Rating)()
      End If
    End Function
    

    Couldn’t you then do a summation:

    Dim controls As IEnumerable(Of AjaxControlToolkit.Rating) = GetRatings(control)
    Dim total As Int32 = Enumerable.Sum(Of AjaxControlToolkit.Rating)(_
        controls, Function(rating) rating.CurrentRating)
    

    If the syntax is way off, let me know, I don’t normally do VB.NET

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic webpage that includes an iFrame where external html code is
I want to have a dynamic webpage that automaticly updates some information, this information
I have a web page that displays dynamic data which changes every 2 seconds.
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have a Dynamic Data Entities Web Application that uses a database with GUIDs
I have a dynamic class that serves as a storage container for configuration settings.
I have a dynamic text file that picks content from a database according to
I have a dynamic list of items that will be used to POST information
I have a flash .swf file that I embed on my webpage. On my
I have a dynamic web page that after clicking a link, I insert a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.