Solved

loop through all the controls

Posted on 2013-01-31
3
244 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
Comment Utility
0
 
LVL 20

Assisted Solution

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

                }
            }

Open in new window

0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

17 Experts available now in Live!

Get 1:1 Help Now