October 15, 2007 0

Recursive Goodness – I

By J in Tags:

Check to see if all the controls within a specific control are valid:

protected bool checkIsValid(Control c)
{
    bool result = true;
    foreach (Control child in c.Controls)
    {

        if (child is BaseValidator && !((IValidator)child).IsValid)
        {
            return false;
        }
        result = result & checkIsValid(child);
    }
    return result;
}

Tags:

Leave a Reply