Loop Through All Controls on an ASP.net Webpage (krissteele.net)

submitted by DigitalDuffmanDigitalDuffman(340) 3 years, 4 months ago

A nifty way using ForEach loops to get all the controls on a webpage.

1 comment |category: |Views: 24

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by brianjlowrybrianjlowry(640) 3 years, 4 months ago 0

Couldn't simple recursion handle this?

public void SomeMethod(Control parent)
{
foreach (var control in parent.Controls)
{
// do something
if (control.Controls.Count > 0)
SomeMethod(control);
}
}

Reply

information Login or create an account to comment on this story