1 / 8

.NET Validation Controls MacDonald Ch. 8

.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

egil
Download Presentation

.NET Validation Controls MacDonald Ch. 8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Validation ControlsMacDonald Ch. 8 MIS 324 Professor Sandvig

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

  3. 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

  4. Benefits and Limitations • Benefits • Convenience • Cut & paste • Bomb-proof • Server-side validation • Limitations • Must remember to check on server • Page.IsValid statement • Different interpretations of regular expressions • JavaScript vs. server • minor issue

  5. Six Validation Controls • RequiredFieldValidator • Only validator that checks for NO entry • CompareValidator • Compares input to: datatype, constant, another control, database value, etc. • RangeValidator • Entry within a specified data range

  6. Six Validation Controls • RegularExpressionValidator • Check format against a specific pattern • E-mail address, phone number, zip code, etc. • CustomValidator • Write own code • Server- or client-side • 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 • Example: • Required, Compare, Range, & Custom (client- and server-side script) • Validation.aspx (source)

  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

More Related