static public void RemoveProblemTypes(ControlCollection coll, List <ControlRestorationInfo> stashedControls) { foreach (Control ctrl in coll) { if (typeof(RequiredFieldValidator).IsAssignableFrom(ctrl.GetType()) || typeof(CompareValidator).IsAssignableFrom(ctrl.GetType()) || typeof(RegularExpressionValidator).IsAssignableFrom(ctrl.GetType()) || typeof(ValidationSummary).IsAssignableFrom(ctrl.GetType())) { ControlRestorationInfo cri = new ControlRestorationInfo(ctrl, coll); stashedControls.Add(cri); coll.Remove(ctrl); continue; } if (ctrl.HasControls()) { RemoveProblemTypes(ctrl.Controls, stashedControls); } } }
static public void RemoveProblemTypes(ControlCollection coll, List<ControlRestorationInfo> stashedControls) { foreach (Control ctrl in coll) { if (typeof(RequiredFieldValidator).IsAssignableFrom(ctrl.GetType()) || typeof(CompareValidator).IsAssignableFrom(ctrl.GetType()) || typeof(RegularExpressionValidator).IsAssignableFrom(ctrl.GetType()) || typeof(ValidationSummary).IsAssignableFrom(ctrl.GetType())) { ControlRestorationInfo cri = new ControlRestorationInfo(ctrl, coll); stashedControls.Add(cri); coll.Remove(ctrl); continue; } if (ctrl.HasControls()) { RemoveProblemTypes(ctrl.Controls, stashedControls); } } }