Analysis on five common controls for ASP. NET data verification

Source: Internet
Author: User

Necessity of ASP. NET data verification: Why data verification is required

Data insertion and update involve user operations. It is inevitable that some users do not know your system, or the user has incorrect hands and incorrect input format. For example, the price should have been a Number "0", and the user accidentally entered the character "o", it will cause an error. Therefore, it is necessary to use technical means to minimize possible errors, which requires data verification.

How to verify ASP. NET data

The most common method is to use JavaScript scripts. When a user clicks the "Log on" button, the script is executed to verify the content entered by the user. This can effectively improve the user experience.

However, JavaScript verification has some disadvantages:

1. JavaScript scripts are not secure enough, and malicious attackers can bypass verification.

2. JavaScript script writing is complicated, and there is no good debugging tool.

Convenient and safe way

ASP. NET provides five data verification controls. Next we will introduce them one by one:

ASP. NET data verification control 1. RequiredFieldValidator

The RequiredFieldValidator control ensures that you provide valid input, that is, non-empty verification. This control is the simplest and most commonly used verification control. It is often used together with other verification controls to verify its validity.

ASP. NET data verification control 2. CompareValidator

The CompareValidator control is used to verify whether the content entered by the user meets the requirements.

ASP. NET data verification control 3. RangeValidator

The RangeValidator control is used for range check. For example, the age group must be between 18 and 22 years old.

ASP. NET data verification control 4. RegularExpressionValidator

RegularExpression is the meaning of a regular expression. A regular expression is a special formula used to match a type of string in a certain pattern.

ASP. NET data verification control 5. CustomValidator

Sometimes the verification is special, so we need to write the verification code ourselves. The CustomValidator control is used for custom verification. The CustomValidator control supports client script verification and server verification.

The content of the ASP. NET data verification control is introduced here. I hope it will help you understand the ASP. NET data verification control.

  1. ASP. NET data import implementation Excel to MSSQL
  2. Example of ASP. NET dataset usage
  3. Analysis on ASP. NET data type conversion
  4. Analysis of validation groups in ASP. NET data verification
  5. Analysis on the use of ASP. NET data verification controls

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.