Reply to comment

Extension

The Same Method with Generic Type and Extension Method

public static T FindControlRecursive(this Control.ControlCollection controls, Control control, string controlName) where T : Control
{
if (control.Name == controlName)
{
T returnControl = control as T;
return returnControl;
}

foreach (Control ctrl in control.Controls)
{
T findControl = controls.FindControlRecursive(ctrl, controlName);
if (findControl != null)
{
return findControl;
}
}
return null;
}

Best Regards
Suleyman Ozturk

Reply