Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print list of conrols on page in Visual Studio 1

Status
Not open for further replies.

theoryofben

IS-IT--Management
Aug 25, 2001
149
US
Hello

I have a page with lots of controls on it. I need to generate a list of them and print it. I can't seem to find the option...I know I must be overlooking something simple. I'm using Visual Studio Professional 2005.

Any help would be greatly appreciated.

Thanks

________________________________________________
[sub]"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison[/sub]

 
you need to recurse through each control starting at the page.
Code:
public class Utility
{
public IEnumerable<string> GetEverySingleControlId(Control control)
{
   var ids = new List<string>();
   ids.Add(control.ID);
   foreach(var child in contorlControls)
   {
        ids.AddRange(GetEverySingleControlId(child));
   }
   return ids;
}
}
usage
Code:
class MyPage : Page
{
public void MyPage_Load(object sender, eventArgs e)
{
   var ids = new Utilty().GetEverySingleControlId(this);
   foreach(var id in ids)
   {
      //do something with id.
   }
}
}

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Thanks...I guess I'll have to do it in code. I thought Visual Studio had a Utility/report that would list them all out. I think 2003 had it...but I guess not 2005.

Thanks for the help.

________________________________________________
[sub]"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison[/sub]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top