Find Controls In MasterPages Recursively
A useful piece of code that enhances the search for the control with the specified name under the passed parent control.
|
On Saturday, October 4th 2008 at 12:51 PM By Andrew Pociu (View Profile)
    (Rated 4 with 1 votes) |
Contextual Ads
More C# Resources
Advertisement
public static Control FindControlR(Control CtrlRoot, string CtrlID)
{
if (Root.ID == CtrlID) // If the name of the control is the same as the name we were looking for
{
return Root; // We've found the control
}
foreach (Control Ctrl in Root.Controls) // Loop through all the controls of the current element
{
Control FoundCtrl = FindControlR(CtrlRoot, CtrlID); // Continue looking
if (FoundCtrl != null)
{
return FoundCtrl;
}
}
return null;
}
|
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|
Rate this code snippet
Current Comments
There are no comments.
|
Related Source Code
There is no related code.
Related Tutorials
There are no related tutorials.
C# Job Search
|