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 6174765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:48:23+00:00 2026-05-23T23:48:23+00:00

I want to ask if I can loop in my controls, like textbox, dropdown

  • 0

I want to ask if I can loop in my controls, like textbox, dropdown list or etc, in which they are in a page’s user control. The scenario is that, assume I have a page called ‘Page.aspx’ and I have 3 user controls in that page(uc1, uc2 and uc3) and an asp panel (named PnlTab1) to contain all these controls in each user control.
I am using that code to reach my controls:


            UserControl uc1, uc2, uc3;
            uc1 = usercontrol1;
            uc2 = usercontrol2;
            uc3 = usercontrol3;

            foreach (Control c in uc1.FindControl("PnlTab1").Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Enabled = true;
            }

            foreach (Control c in uc2.FindControl("PnlTab1").Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Enabled = true;
            }
            foreach (Control c in uc3.FindControl("PnlTab1").Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Enabled = true;
            }

Now, I do not want to write each time ‘foreach (Control c in uc3.FindControl("PnlTab1").Controls‘ . Can I recursively do that?

Thank you all a lot!

  • 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-23T23:48:24+00:00Added an answer on May 23, 2026 at 11:48 pm

    no need for recursion, just another loop:

       UserControl[] ucs = new UserControl[3]{
             usercontrol1,
             usercontrol2,
             usercontrol3
       };
       foreach (UserControl uc in ucs){
            foreach (Control c in uc.FindControl("PnlTab1").Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Enabled = true;
            }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to ask how can someone read keystrokes while in a html page
I want to ask in which phase of Control Execution Lifecycle is the Server-Side-Code
want to ask user to input something but not want to wait forever. There
What I want to do is ask the user for a number of strings
Just want to ask, can you copy one entire directory to multiple destination? Example
I have a script and want to ask the user for some information, but
So my program, when instantiated asks the user how many items they want. My
I'm learning C++. nav is an integer . I want to ask user for
I'm trying to create a program where the user enter a string which can
i want ask some question about asp.net mvc Is static constructor will init every

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.