Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

loop through all the controls

Posted on 2013-01-31
3
Medium Priority
?
271 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 1000 total points
ID: 38840288
0
 
LVL 20

Assisted Solution

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

                }
            }

Open in new window

0
 
LVL 60

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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