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;
 }
asked Jun 16, 2011 at 7:26
\$\endgroup\$

1 Answer 1

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

answered Jun 16, 2011 at 11:48
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.