Client verification of ASP. NET-Asp. NET Server controls

Source: Internet
Author: User

If the browser you are using supports dynamic HTML (DHTML), the ASP. NET verification control can be verified using the client script. This control can provide timely feedback (no round-trip to the server is required), so users will feel that the page performance has improved.

In most cases, client verification is available without making any changes to the page or verification control. The control automatically checks whether the browser supports DHTML and performs the corresponding check. The error display mechanism used by client verification is the same as that used by server verification.

 

I. Differences in client Verification

If verification is performed on the client, the verification control can include some additional features:

· If you want to generate a summary of verification error messages, you can display the information in the message box, which appears when the user submits the page.

· The object model of the verification control is slightly different on the client.

 

Client verification has the following nuances:

· If client verification is enabled, the page contains references to the script library used for client verification.

· When using the regularexpressionvalidator control, if you can use a language compatible with ecmascript (such as Microsoft JScript), you can check the expression on the client. The client-side Regular Expression check is slightly different from the regular expression check performed by the RegEx class on the server.

· The page contains client methods to intercept and process click events before Page Submission.

 

Ii. client-side object Verification Model

The object model presented by the verification control on the client is almost the same as that presented on the server. For example, whether on the client or on the server, you can read the isvalid attribute of the verification control in the same way to test the verification.

However, the verification information exposed at the page level is different. On the server, the page supports properties. On the client, it contains global variables. The following table compares the information published on the page.

Client page Variables

Server Page Properties

Page_isvalid

Isvalid

Page_validators (array) contains references to all verification controls on the page.

Validators (SET) contains references to all verification controls.

Page_validationactive indicates whether a Boolean value should be verified. Programmatically set this variable to false to disable Client verification.

(No equivalent items)

Note: All page-related verification information should be considered as read-only information.

 

3. Send a page with client verification errors

In some cases, you may not want to use client-side authentication, but only server-side authentication, even if you can use client-side authentication. For example, if the authentication requires the use of information or resources (such as accessing the database) that are only available to the server, the client authentication is not feasible.

By default, if an error occurs on the page during client verification, you cannot send the page to the server. However, you may find it necessary to allow users to send messages even when an error occurs. For example, there may be a Cancel button or a navigation button on the page. You need this button to submit the page even if some controls fail verification.

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.