2
\$\begingroup\$

There is Three Validation Group A,B and No Group.

How to get validation result of only the specific validation group.

If Group A and No Group is not valid but all of group B is valid, i would like to get result as valid.

I have read the article validation in depth but don't find the straightforward solution. http://msdn.microsoft.com/en-us/library/aa479045.aspx

Is there any simpler solution than this

    protected bool IsGroupB_Valid()
    {
        var validators = Page.GetValidators("B");

        foreach (IValidator item in validators)
        {
            if(item.IsValid == false)
            return false;
        }
        return true;
    }
\$\endgroup\$
4
\$\begingroup\$

Linq will make it look better:

protected bool IsGroupB_Valid()
{
    return Page.GetValidators("B").All(v => v.IsValid);
}

But probably you should look for something really different

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.