protected static bool CheckForErrors( ICollection controls )
{
bool hasError = false;
foreach (Control control in controls)
{
PropertyInfo pi = control.GetType().GetProperty( "HasErrors" );
if (pi != null)
{
object obj = pi.GetValue( control, null );
if (obj is bool)
hasError |= (bool) obj;
}
hasError |= CheckForErrors( control.Controls );
if (hasError)
break;
}
return hasError;
}