views:

41

answers:

1

Hi,

Is there any way to assign a group of asp.net validations to validate when a button is clicked?

I've got two sections in my site. If one section isn't submitted and the user decides to submit the other, I want to prevent the validation from the first section from firing also.

Any suggestions or pointers? Thanks

+5  A: 

Set the ValidationGroup on both your validators and button to be the same value to tie them together. In the example below, there are 2 buttons, each one validates one section or the other, but not both.

<asp:RequiredFieldValidator runat="server" ... ValidationGroup="GroupOne" />
<asp:RequiredFieldValidator runat="server" ... ValidationGroup="GroupTwo" />
<asp:Button runat="server" ID="ButtonOne" ... CausesValidation="true" ValidationGroup="GroupOne" />
<asp:Button runat="server" ID="ButtonTwo" ... CausesValidation="true" ValidationGroup="GroupTwo" />
Scott Ivey
Dam its that easy! Thanks Scott.
Vince