I have 2 buttons which validates different sets of textboxes (which have corresponding asp validators). How can I control the validations triggered by each button?
Validation Group in ASP.NET 1.1
342 views Asked by user2545231 At
2
There are 2 answers
0
On
You have to set the same Group name for each set of textbox and buttons .
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="GroupOne"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1"
ErrorMessage="ErrorMessageForTextBox1" ValidationGroup="GroupOne">
</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="GroupOne" />
<asp:TextBox ID="TextBox2" runat="server" ValidationGroup="GroupTwo"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2"
ErrorMessage="ErrorMessageForTextBox1" ValidationGroup="GroupTwo">
</asp:RequiredFieldValidator>
For ASP version 1.1 , use this link !
Add ValidationGroup="set1" and ValidationGroup="set2" properties to your textboxes, buttons, Validators and Validation Summaries, that should do it.