| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- namespace GreenTree.Nachtragsmanagement.Web.Extensions
- {
- public static class ControlHelper
- {
- public static Control[] GetAllSubControlsOfTypes(this Control control, params Type[] types)
- {
- var result = new List<Control>();
- GetSubControls(control, result, types);
- return result.ToArray();
- }
- private static void GetSubControls(Control parent, List<Control> result, Type[] types)
- {
- if (parent == null) return;
- foreach (Control subControl in parent.Controls)
- {
- if (subControl.Controls.Count > 0)
- GetSubControls(subControl, result, types);
- foreach (var type in types)
- {
- if (subControl.GetType() == type)
- {
- result.Add(subControl);
- break;
- }
- }
- }
- }
- }
- }
|