. Net multiple button events on a page to avoid data verification control requiredfieldvalidator conflict

Source: Internet
Author: User

I:

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 validationgroup for another button.
<Asp: button id = "buttonok" runat = "server" text = "quit" onclick = "exit_click"/>

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 validationgroup for another button.
<Asp: button id = "buttonok" runat = "server" text = "quit" onclick = "exit_click"/>

II:

There are multiple verification controls on a page and verification issues after the control is submitted.
For example, there are two input boxes: T1: val1 (corresponding verification control)
T2: val2 (corresponding verification control)
And two buttons: Bt1 and bt2. Bt1 corresponds to T1 and bt2 corresponds to T2.
After you click submit, the system will verify the request first. In this case, the process is as follows:
Attributes of the two verification controls: enabled = "false" enableclientscript = "false"
When you click Bt1, the corresponding event handler is written as follows:
Val2.enabled = false;
Val1: enabled = true;
Page. Validate ();
If (page. isvalid)
{
........
}

Similarly, bt2 corresponds:
Val1.enabled = false;
Val2.enabled = true;
Page. Validate ();
If (page. isvalid)
{
......
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.