How to clear a Multiple TextBox values in a single click in C# .NET
We can better have an extension like: public static class ControlExtension { public static IList FindControlByName(this Control control) where T : Control { List controlsFound = new List(); controlsFound.AddRange(control.Controls.OfType()); ...
We can better have an extension like:
public static class ControlExtension
{
public static IList<t> FindControlByName<t>(this Control control) where T : Control
{
List<t> controlsFound = new List<t>();
controlsFound.AddRange(control.Controls.OfType<t>());
foreach (Control c in control.Controls)
{
controlsFound.AddRange(FindControlByName<t>(c));
}
return controlsFound;
}
}
and perform:
this.FindControlByName<textbox>().ToList().ForEach(t => t.Clear());