Solved

loop through all the controls

Posted on 2013-01-31
3
247 Views
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?
0
Comment
Question by:VBdotnet2005
3 Comments
 
LVL 3

Accepted Solution

by:
Nalinkumarbalaji earned 250 total points
ID: 38840288
0
 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 250 total points
ID: 38840293
foreach (Control ctrl in Page.Controls)
            {
                if (ctrl.GetType() == typeof(TextBox))
                {

                }
            }

Open in new window

0
 
LVL 52

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

http://stackoverflow.com/questions/4955769/better-way-to-find-control-in-asp-net
http://stackoverflow.com/questions/2209854/find-all-child-controls-of-specific-type-using-enumerable-oftypet-or-linq
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now