1 / 14

CSCI 6962: Server-side Design and Programming

CSCI 6962: Server-side Design and Programming. Validation Controls. ASP Validation Controls. ASP automatically reposts same page, echoes original values back Validation controls can be attached to other controls to insure they contain legal values

jud
Download Presentation

CSCI 6962: Server-side Design and Programming

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. CSCI 6962: Server-side Design and Programming Validation Controls

  2. ASP Validation Controls • ASP automatically reposts same page, echoes original values back • Validation controls can be attached to other controls to insure they contain legal values • IsValidoperator used in conditions that cause page redirection • Can specify client-side or server-side validation

  3. Validation Controls • In Validation section of Toolbox • Usually dragged next to corresponding control so errormessage displayed next to it • Control must have CausesValidation property setto true

  4. Validation Control Properties • Key properties shared by all: • ID • ControlToValidateControl this validator is associated with • ErrorMessageMessage to display in validator if value is not valid • EnableClientScriptFalse to force JavaScript-based validation on server side(must be set to avoid errors)

  5. Required Field Validator • Requires control to have a value • Strings trimmed before evaluation • Can be used on any list-based control

  6. Required Field Validator • Can set InitialValue property • Validation checks whether the property has changed • Useful if control has a value (lists, for example)

  7. Validation and Redirection • Usually only redirect to next page if all fields valid on current page • Can check with Page.IsValid • Make part of condition for redirection

  8. Compare Validator • Used to compare control value to some limit • ValueToCompare: limiting value • Operator: How comparison done • Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual C

  9. Compare Validator • Can also be used for type checking • Operator = DataTypeCheck • Set Type property C C

  10. Regular Expression Validator • Key property: ValidationExpression • ASP provides list of commonly used expressions C

  11. Regular Expression Validator • Can create own regular expression in expression chooser C C

  12. Multiple Validators • Often attach multiple validators to same control if more than one property must be validated • Example: WidgetBox • Must have value (RequiredValidator) • Must be an integer (CompareValidator with DataTypeCheck) • Must be at least 1 (CompareValidator with GreaterThanEqual) • Must set Display property to Dynamic • Otherwise, “space” for inactive validator present C

  13. Custom Validation • Writing code for validation • Function called: IDofValidator_ServerValidate

  14. Custom Validation • Purpose: Set args.IsValid flag (True if valid False if not) C

More Related