Solved

loop through all the controls

Posted on 2013-01-31
3
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 57

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need syntax help building hyperlink 2 53
ASP.NET data base connection 35 95
asp.net mvc5 6 34
Difference between Highcharts and Mapbox 10 45
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…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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