1

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?

user2545231
  • 245
  • 3
  • 10

2 Answers2

0

Add ValidationGroup="set1" and ValidationGroup="set2" properties to your textboxes, buttons, Validators and Validation Summaries, that should do it.

Tamim Al Manaseer
  • 3,554
  • 3
  • 24
  • 33
0

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 !

zey
  • 5,939
  • 14
  • 56
  • 110