Presentation is loading. Please wait.

Presentation is loading. Please wait.

.NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.

Similar presentations


Presentation on theme: ".NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig."— Presentation transcript:

1 .NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig

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

3 What Validation Controls Do Each control: –Validates user inputs on client-side using JavaScript When possible –Validates all inputs on server –Writes client-side error message if invalid

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

5 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

6 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

7 Implementation Often need > 1 validator per input –Only RequiredFieldValidator checks for empty fields Page.IsValid –Check in event handler if (!Page.IsValid) 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 No groups No groups Example: –Required, Compare, Range, & Custom (client- and server-side script) –Validation.aspx (source) Validation.aspxsourceValidation.aspxsource

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


Download ppt ".NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig."

Similar presentations


Ads by Google