Validation Server Control - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Validation Server Control

Description:

We have many kinds of control: HTML, HTML server control, ... Validators. Buttons cause the validator. SetFocusOnError = 'true' Q & A. In class exercise 5 ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 18
Provided by: quoc6
Category:

less

Transcript and Presenter's Notes

Title: Validation Server Control


1
Validation Server Control
Chapter 3
2
Objectives
  • Understanding validation
  • Client side and Server side validation
  • ASP.NET Validations
  • Turning off Client-side validation
  • Using Images and Sound for error notification
  • Validation Group

3
1. Understanding validation
  • We have many kinds of control HTML, HTML server
    control, ASP.NET web control
  • Remember that you have no way to validate the
    truthfulness of the information you collect.

4
2. Client side and Server side validation
Use both of them
5
3. ASP.NET Validations
  • 3.1 ASP.NET Validations properties
  • 3.2 six validation server

6
3.1 ASP.NET Validations properties
  • ASP.NET performs browser detection.
  • If it support JS ? use client-side check
  • If not support JS ? use server-side check
  • Validation causes
  • It occurs in response to an event (all buttons)
    with CausesValidation properties

7
3.2 six validations server
  • 3.2.1 RequiredFieldValidation
  • 3.2.2 CompareValidator
  • 3.2.3 RangeValidator
  • 3.2.4 RegularExpressionValidator
  • 3.2.5 CustomValidator
  • 3.2.6 ValidationSummary

8
3.2.1 RequiredFieldValidation
  • Common Properties ErrorMessage,
    ControlToValidate
  • InitialValue ? check with default value
  • Disallowing blank entries and requiring changes
    at the same time gt two RequiredFieldValidator
    controls

9
3.2.2 CompareValidator
  • Validating against other controls (between two
    form elements)
  • Properties ControlToCompare
  • Validating against constants (data type)
  • Type (can be currency, date, double, integer,
    string)
  • Operator DataTypeCheck
  • Validating against constants ( specific
    constants)
  • Operator ,gt,gt,lt,lt, !
  • ValueToCompare
  • Type String, integer,..

10
3.2.3 RangeValidator
  • Type, MinimumValue, MaximumValue

11
3.2.4 RegularExpressionValidator
  • ValidationExpression
  • Many template with expression editor
  • www.regexlib.com

12
3.2.5 CustomValidator
  • we can choose client-side or server-side
    validation
  • Client-side validation
  • ClientValidationFunction js_fun
  • Server-side validation
  • OnServerValidate fn_name
  • Make the validation as complex as application
    require
  • Check with dynamic value from database
  • BothUse two properties at the same time

13
3.2.6 ValidationSummary
  • Report for all validation errors
  • Output with list, bulleted list, paragraph
  • Output with dialog using ShowMessageBox true
  • ShowSummary false

14
4. Turning off Client-side validation
  • All validation control have EnableClientScript
    true (default) or false

15
5. Using Images and Sound for error notification
  • Image
  • ErrorMessage ltimg src.gifgt
  • Sound
  • ErrorMessageltbgsource src.wavgt
  • Note you have to disable client-side script
  • EnableClientScript false if you dont want
    the sound plays when page is loaded

16
6. Validation Group
  • ValidationGroup groupname
  • Validators
  • Buttons cause the validator
  • SetFocusOnError true

17
Q A
  • In class exercise 5
  • Name your website your_name_inclass1 zip it and
    email to huynq_at_saigontech.edu.vn
Write a Comment
User Comments (0)
About PowerShow.com