0

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.

3 Answers 3

4

Yes, you can use ValidationGroup property of the validators and the controls that causes validation like buttons.

Sign up to request clarification or add additional context in comments.

Comments

2

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).

Comments

1

Use validation groups

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.