NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Client-Side Validation

If the user is working with a browser that supports Dynamic HTML (DHTML), such as Internet Explorer 4.0 or higher, validation controls can perform validation using client script. Because the controls can provide immediate feedback (without a round trip to the server), the user experience with the page is enhanced.

Under most circumstances, you do not have to make any changes to your page or to the validation controls. They detect automatically if the browser supports DHTML and perform their checking accordingly. Client-side validation uses the same error display mechanism as server-side checking.

Note   Validation is performed on the server even if it was already performed on the client. This allows you to check validation status in server code and provides security against users bypassing validation.

Differences in Client-Side Validation

There are some additional features of validation available if it is performed on the client:

Client Validation Object Model

Validation controls present almost the same object mode on the client as on the server. For example, you can test validation by reading the value of a validation control's IsValid property the same way on both the client and the server.

However, there are differences in the validation information exposed at the page level. On the server, the page supports properties; on the client, it contains global variables. The following table compares the information exposed on the page.

Server Page Property Client Page Variable
IsValid Page_IsValid
Validators (collection)   Contains references to validation controls whose IsValid property has changed since the last round trip to the server. Page_Validators (array)   Contains references to all validation controls on the page, regardless of change in their status.
(no equivalent) Page_FieldsToValidate (array)   A list of references to all the input controls being validated. This array is used internally by the validation controls.
Note   All page-related validation information should be considered read only.

Automatic Client-Side Validation

Client-side validation is enabled automatically if you are using Microsoft Internet Explorer 4.0 or later. In some instances, however, you might prefer server-side validation even if client-side validation is possible. For example, server-side validation might be required if the validation requires information or resources that are only available on the server, such as access to a database. For details, see Controlling Client versus Server Validation.

Note   Client-side validation requires that your browser support Dynamic HTML and Visual Basic.

Posting with Client-Side Validation Errors

By default, when client-side validation is being performed, the user cannot post the form to the server if there are errors on the page. However, you might find it necessary to allow the user to post even with errors. For example, if the user is working with a multi-page entry form, an error on the first page might be resolved by an entry on a subsequent page. For details, see Allowing Posting with Client-Side Validation Errors.

See Also

Validation Controls