ValidationSummary does not work if the ValidationGroup parameter is specified

I have several sections on an ASP.NET page and need to be checked separately.

Each section has its own summary part of the check, so I thought about using the ValidationSummary tag with the attribute ValidationGroup, but it does not work.

The following code works, but checks all the controls on the page:

<asp:TextBox ID="field1" runat="server" TabIndex="1" MaxLength="20" />
<asp:RequiredFieldValidator ID="field1RequiredValidator" ControlToValidate="field1" runat="server"
Display="None" ErrorMessage="mandatory 1" />

<asp:TextBox ID="field2" runat="server" TabIndex="2" MaxLength="20" />
<asp:RequiredFieldValidator ID="field2RequiredValidator" ControlToValidate="field2" runat="server"
Display="None" ErrorMessage="mandatory 2" />

....

<asp:ValidationSummary ID="validationSummary" HeaderText="Sumary" runat="server" />

While the following does not work (no verification whatsoever, on sending I just go to the next page in the wizard):

<asp:TextBox ID="field1" runat="server" TabIndex="1" MaxLength="20" />
<asp:RequiredFieldValidator ID="field1RequiredValidator" ControlToValidate="field1" runat="server"
Display="None" ErrorMessage="mandatory 1" ValidationGroup="xxxx" />

<asp:TextBox ID="field2" runat="server" TabIndex="2" MaxLength="20" />
<asp:RequiredFieldValidator ID="field2RequiredValidator" ControlToValidate="field2" runat="server"
Display="None" ErrorMessage="mandatory 2" ValidationGroup="xxxx" />

....

<asp:ValidationSummary ID="validationSummary" HeaderText="Sumary" runat="server" ValidationGroup="xxxx" />

What am I missing here? Is additional configuration required or something else?

+5
source share
1 answer

ASP.NET , , ValidationGroup ( CausesValidation true), , , .

ValidationGroup , ( CausesValidation).

. MSDN Button.ValidationGroup.

EDIT: , - , , . ( ) , ( ), :

Validate("groupOne");
Validate("groupTwo");
// ...

, . ., , .

EDIT: , , ASP.NET, , , .

+15

All Articles