ASP.NET Which validationgroup caused validation fail

1k Views Asked by At

There are 3 validation groups on the page

Group1
Group2
Group3

After validating the groups

Page.Validate("Group1");
Page.Validate("Group2");
Page.Validate("Group3");

Page.IsValid is false

How can I find out which group caused validation to fail and which ones passed?

3

There are 3 best solutions below

3
On

Check Page.IsValid after each call.

1
On

Why not checking right after calling validate?

0
On
Page.Validate("Group1");
if (!Page.IsValid)
    return "Group 1 did not validate";

Page.Validate("Group2");
if (!Page.IsValid)
    return "Group 2 did not validate";

Page.Validate("Group3");
if (!Page.IsValid)
    return "Group 3 did not validate";