Reputation: 4036
Is there a way to tie the validation of certain controls to one button on an ASP.Net web form and tie the validation of other controls to a different button? For instance, if I have 6 textboxes (A, B, C, D, E, and F) and two button controls, I'd like to only call the validation on textboxes A, B, and C if button 1 is clicked. If button 2 is clicked, I'd like to only call the validation on textboxes D, E, and F.
Upvotes: 0
Views: 229
Reputation: 26190
Use the ValidationGroup field for each control. Mark textboxes A, B, C and button 1 as ValidationGroup = 'Group 1', or something similar. Do the same for textboxes D,E,F and button 2, with a different group name. This way, only controls with matching group names will be validated when a button with that name is pressed (in your case).
Upvotes: 2
Reputation: 48088
Yes, you can use ValidationGroup property of the validators and the controls that causes validation like buttons.
Upvotes: 4