Asp. NET one page multiple button buttons events avoid data validation controls RequiredFieldValidator conflict methods

Source: Internet
Author: User


Description: InThere is no better way to do this than hack code in ASP. NET 1.1.This problem can be easily resolved by adding the Validatorgroup property to all validator controls and buttons (button, LinkButton, and so on) in ASP. NET 2.0. If there is a textbox in the page and next to him there is a RequiredFieldValidator and button control, The ValidationGroup property of the RequiredFieldValidator and button can be set to the same value so that only the validor of the RequiredFieldValidator is triggered when the button is clicked, Any other validator that are not defined within the ValidationGroup will be ignored.

Example:
text boxes and data validation controls:
<asp:textbox id= "Txtoldps" runat= "Server" width= "150px" ></asp:TextBox>
<asp:requiredfieldvalidator id= "RequiredFieldValidator1" runat= "Server" controltovalidate= "Txtoldps"
Display= "None" errormessage= "<b> friendly reminder </b><br/> Please enter the original password!! "Validationgroup=" ></asp:RequiredFieldValidator> "ValidataGroup1"

Button event:
<asp:button id= "Buttonok" runat= "Server" text= "Modify" onclick= "Edit_click" validationgroup= "ValidataGroup1"/>

The other button does not need to be set ValidationGroup
<asp:button id= "Buttonok" runat= "Server" text= "Exit" onclick= "Exit_click"/>

Focus: Verify that the control and button settings are the same as the validationgroup= "ValidataGroup1" property value.

Asp. NET one page multiple button buttons events avoid data validation controls RequiredFieldValidator conflict methods

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.