Problem description: create multiple buttons on a page. By default, the button event conflicts with the data verification control: when one of the buttons is clicked, you want a specific validator to be fired, instead of all validator on the page. Validator is not required for other buttons. The data verification control is enabled.
Note: There is no better way except the hack code in ASP. NET 1.1. ASP. NET
In 2.0, the validator group attribute is added to all validator controls and buttons (buttons, linkbuttons, and so on) to easily solve this problem.
Problems. If there is a textbox in the page and there is a requiredfieldvalidator next to it
And the button control, you can set the validationgroup attribute of requiredfieldvalidator and button to the same value, so that the point
When you click a button, only the valider of requiredfieldvalidator is triggered.
Validator is ignored.
Example:
Text Box and data verification controls:
<Asp: textbox id = "txtoldps" runat = "server" width = "150px"> </ASP: textbox>
<Asp: requiredfieldvalidator id = "requiredfieldvalidator1" runat = "server" controltovalidate = "txtoldps"
Display = "NONE" errormessage = "<B> reminder </B> <br/> enter the original password !! "Validationgroup = "validatagroup1"> </ASP: requiredfieldvalidator>
Button event:
<Asp: button id = "buttonok" runat = "server" text = "modify" onclick = "edit_click"Validationgroup = "validatagroup1"/>
You do not need to set another buttonValidationgroup
<Asp: button id = "buttonok" runat = "server" text = "quit" onclick = "exit_click"/>