0% found this document useful (0 votes)
132 views8 pages

.NET Validation Controls Guide

This document discusses .NET validation controls which validate user input on both the client-side and server-side. It describes six common validation controls: RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator, and ValidationSummary. The benefits of validation controls are that they are convenient to use and provide bomb-proof server-side validation, while a limitation is remembering to check validation on the server. An example implementation uses multiple validators per input and groups validators to allow validation to occur independently for different parts of a form.

Uploaded by

chandan_padalkar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views8 pages

.NET Validation Controls Guide

This document discusses .NET validation controls which validate user input on both the client-side and server-side. It describes six common validation controls: RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator, and ValidationSummary. The benefits of validation controls are that they are convenient to use and provide bomb-proof server-side validation, while a limitation is remembering to check validation on the server. An example implementation uses multiple validators per input and groups validators to allow validation to occur independently for different parts of a form.

Uploaded by

chandan_padalkar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

.

NET Validation Controls


MacDonald Ch. 8 MIS 324 Professor Sandvig

Today
What Validation controls do Benefits & Limitations Six Validation Controls Implementation Example

What Validation Controls Do


Validate User inputs
~75% of code for handling exceptions Simplify task

Each control:
Validates user inputs on client-side using JavaScript
When possible

Validates all inputs on server Writes client-side error message if invalid

Benefits and Limitations


Benefits
Convenience
Cut & paste

Bomb-proof
Server-side validation

Limitations
Must remember to check on server
[Link] statement

Different interpretations of regular expressions


JavaScript vs. server minor issue

Six Validation Controls


1. RequiredFieldValidator Only validator that checks for NO entry 2. CompareValidator Compares input to: datatype, constant, another control, database value, etc.

3. RangeValidator Entry within a specified data range

Six Validation Controls


4.

RegularExpressionValidator
Check format against a specific pattern E-mail address, phone number, zip code, etc.

5.

CustomValidator
Write own code Server- or client-side

6.

ValidationSummary
Summarizes all errors on page

Implementation
Often need > 1 validator per input
Only RequiredFieldValidator checks for empty fields

[Link]
Check in event handler
if (![Link]) return;

Validation Groups
Allow validation controls to be assigned to groups Page can have several groups Act independently Only group associated with postback event must have valid entries Example: No groups, groups

Example:
Required, Compare, Range, & Custom (client- and server-side script) [Link] (source)

Summary
Easy to use Flexible
Validate any type of input

Combines client- and server-side validation in one control Bomb-proof server-side validation

You might also like