Asp. Select validation of form input rows in net

Source: Internet
Author: User
In ASP.net, there is a series of validation controls that make it easy to verify that the data entered by the user is legitimate. Although these validation controls are powerful and easy to use, they have one drawback: generally, when using them, the user input to the entire page is validated when the page is submitted. In a validation control, there is no direct way to validate only the input of parts of a page. This article describes how to use the ASP.net validation controls and JavaScript features to complete the ability to validate only the input of parts of a page.
Why do you have to validate the input of some parts of a page? For example, in some applications, sometimes for the convenience of user input, it is possible that on the same page, there are multiple forms that require users to input data and submit data (this is common in some information system background management systems). And the user does one operation at a time, for example, the user input each purchase quantity and submit, then only need to validate the submitted data, and other forms of the page, such as the number of each shipment, because the user did not fill in the data, you do not need to check it, this also improves the efficiency of the application.
Let's take a look at how to selectively validate form input, beginning with a comprehensive understanding of some of the properties and usages of the input validation controls in the next asp.net.
The first introduction is the CausesValidation property. If we do not want to validate the events submitted by a button, simply set the CausesValidation property to False, for example, with a Cancel button, you can set this:

Another way to do this is to:
Cmdcancel.causesvalidation=false;
This way, once the CausesValidation property is set to False, the validation of either the client or the server will not work.
If you want to selectively validate portions of a page, you will need to implement some of the methods and javascrpt of the validation control, and the following list lists some of the methods and properties in the validation control:
Name
Describe
Page_isvalid
Verify that all input in the page is valid and return a Boolean value
Page_Validators
An array of all validation controls in the current page
Related Article

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.