Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can you loop through all controls on an ASP.NET Web form?

user-image
Question added by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date Posted: 2013/01/08
marwa khalaf
by marwa khalaf , .Net Developer , Sands National Academy

You can easily traverse all controls on a form via the Web Form’s Controls collection.
The GetType method can be used on each control to determine its type and how to work with it.
Now, it gets tricky because the form contains a tree of controls; that is, some controls are contained within others (think of a Table).
You would have to recursively loop through the controls to make sure everything is processed.

Omar Alsoudani
by Omar Alsoudani , Software Engineer , Codeobia , Amman

Web Form’s Controls collection

Furqan Ul Karim
by Furqan Ul Karim , Senior Delivery Manager (Contract) , Virgin Red

using for each loop with the page controls collection .
Easy isn't it.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.