loop through all the controls

Posted on 2013-01-31
Medium Priority
Last Modified: 2013-01-31
How can I loop through all the controls on my page and setting certain types (TextBox, CheckBox, DropDownList, etc.) to Enabled=False under certain conditions?
Question by:VBdotnet2005

Accepted Solution

Nalinkumarbalaji earned 1000 total points
ID: 38840288
LVL 20

Assisted Solution

by:Obadiah Christopher
Obadiah Christopher earned 1000 total points
ID: 38840293
foreach (Control ctrl in Page.Controls)
                if (ctrl.GetType() == typeof(TextBox))


Open in new window

LVL 62

Expert Comment

by:Julian Hansen
ID: 38840449
Remember controls can themselves contain controls so you will need to recursively check controls for children as well. These articles might help


Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question