2

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?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
RubyWedge
  • 157
  • 6

3 Answers3

2

Check Page.IsValid after each call.

Daniel Dyson
  • 13,192
  • 6
  • 42
  • 73
  • `+1` That's the kind of answer everyone knows, but no-one thinks of. – sshow Jun 23 '10 at 11:41
  • No. If Group1 fails Page.IsValid is always false after checking Group2 and Group3 even if they are valid. I need to know exactly valid/or not for each group. – RubyWedge Jun 23 '10 at 11:45
  • Page.IsValid validates all validators in active validation group so you have 2 options. Either set all validators IsValid property to true, or create empty group and validate it before validating your next group – Sergej Andrejev Jun 23 '10 at 12:02
1

Why not checking right after calling validate?

Sergej Andrejev
  • 9,091
  • 11
  • 71
  • 108
  • I need to know valid or not for each group but Page.IsValid set to fals after the first validation fail. – RubyWedge Jun 23 '10 at 11:47
1
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";
sshow
  • 8,820
  • 4
  • 51
  • 82