NET Validation Controls Today What Validation controls do

  • Slides: 8
Download presentation
. NET Validation Controls

. NET Validation Controls

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

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

What Validation Controls Do Each control: – Validates user inputs on client-side using Java.

What Validation Controls Do Each control: – Validates user inputs on client-side using Java. Script 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

Benefits and Limitations Benefits – Convenience Cut & paste – Bomb-proof Server-side validation Limitations – Must remember to check on server Page. Is. Valid statement

Six Validation Controls 1. Required. Field. Validator – Only validator that checks for NO

Six Validation Controls 1. Required. Field. Validator – Only validator that checks for NO entry 2. Compare. Validator – Compares input to: datatype, constant, another control, database value, etc. 3. Range. Validator – Entry within a specified data range

Six Validation Controls 4. Regular. Expression. Validator – Check format against a specific pattern

Six Validation Controls 4. Regular. Expression. Validator – Check format against a specific pattern – E-mail address, phone number, zip code, etc. 5. Custom. Validator – Write own code – Server- or client-side 6. Validation. Summary – Summarizes all errors on page

Implementation Often need > 1 validator per input – Only Required. Field. Validator checks

Implementation Often need > 1 validator per input – Only Required. Field. Validator checks for empty fields Page. Is. Valid – Check in event handler if (!Page. Is. Valid) 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) – Validation. aspx (source)

Summary Easy to use Flexible – Validate any type of input Combines client- and

Summary Easy to use Flexible – Validate any type of input Combines client- and server-side validation in one control Bomb-proof server-side validation