I need to process a specific Control in a Web Page's Controls collection.
I do know the ID of the control.
I simply need to pass a reference to it to another method.
The following code works - but I suspect it's overly complicated for what
I'm trying to do. So, what is a simpler way to get the reference to the
Control that has the ID "MyControl" - simpler than looping through the
Controls collection?
foreach(System.Web.UI.Control c in Controls) {
if (c.ID == "MyControl") {
DoSomething(c);
break;
}
}
Thanks!