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;
}
1 Answer 1
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