If you set the “CausesValidation” property to false, it will disable validation all together on the button.
Check out the "ValidationGroup" property. It allows you to group controls together to allow for a more granular validation behaviour.
Just add the ValidationGroup property to the controls that you want to group together and then add the same ValidationGroup to the control that should execute the validation on postback.
EG
-
<asp:textbox id=“TextBoxA" runat=“server”/>
-
<asp:requiredfieldvalidator ValidationGroup=“Group1” ErrorText=“Need to Fill in Value!” ControlToValidate=“TextBoxA” runat=“server”/>
-
-
<asp:textbox id=“TextBoxB" runat=“server”/>
-
<asp:requiredfieldvalidator ValidationGroup=“Group1” ErrorText=“Need to Fill in Value!” ControlToValidate=“TextBoxB” runat=“server”/>
-
-
<asp:textbox id=“TextBox1” runat=“server”/>
-
<asp:requiredfieldvalidator ValidationGroup=“Group2” ErrorText=“Need to Fill in Value!” ControlToValidate=“TextBox1” runat=“server”/>
-
-
<asp:textbox id=“TextBox2” runat=“server”/>
-
<asp:requiredfieldvalidator ValidationGroup=“Group2” ErrorText=“Need to Fill in Value!” ControlToValidate=“TextBox2” runat=“server”/>
-
-
<asp:button text=“Group1” ValidationGroup=“Group1” runat=“server” ID="FirstButton"/>
-
<asp:button text=“Group2” ValidationGroup=“Group2” runat=“server” ID="SecondButton"/>
-
The above code will execute validation for Group 1 (which validates TextBoxA and TextBoxB) when the first button is clicked, and will execute validation for Group 2 (which validates Textbox1 and Textbox2) when the second button is clicked.
Cheers!
-Frinny