Web Development Using ASP 'NET - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Web Development Using ASP 'NET

Description:

... Controls inherit from the Base Validator class, which inherits from the ... to summarize the error messages from validators ona web page, in one location. ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 13
Provided by: skj1
Category:

less

Transcript and Presenter's Notes

Title: Web Development Using ASP 'NET


1
Web Development Using ASP .NET
Welcome to week 5-1 of
  • CA 240
  • Kashif Jalal

2
Validation Controls
3
Validation Controlspages 116 119
  • An important aspect of creating ASP.NET Web pages
    for user input is to be able to check that the
    information users enter is valid. ASP.NET
    provides a set of validation controls that
    provide an easy-to-use but powerful way to check
    for errors and, if necessary, display messages to
    the user.
  • Validation Controls are used to compare your form
    field controls to a rule.
  • Validation Controls are also used to configure
    the rules to validate the contents of form
    fields.
  • The Validation Controls inherit from the Base
    Validator class, which inherits from the Label
    class.

4
Types of Validation Controls
  • RequiredFieldValidator
  • RangeValidator
  • CompareValidator
  • RegularExpressionValidator
  • CustomValidator
  • ValidationSummary

5
RequiredFieldValidator
  • Ensures that the user does not skip an entry.
  • Ensures if a value is entered or selected.
  • If the field is cleared, the user sees an error
    message immediately when leaving the field.
  • In server-side validation, no checking is done
    until the page is submitted, so the user will not
    see an error message until after the page is
    submitted.

6
RangeValidator
  • Checks whether the value of an Input control is
    within a specified range of values.
  • In addition to ControlToValidate property, you
    must assign the Minimum and Maximum Value
    properties to specify range.
  • Data types that can be compared are strings,
    integers, doubles, dates, and currency.

7
CompareValidator
  • Compares a user's entry against a constant value,
    against the value of another control (using a
    comparison operator such as less than, equal, or
    greater than), or for a specific data type.
  • You must specify the Input control to validate by
    setting the ControlToValidate property.
  • If you want to compare a specific Input control
    with another Input control, then set
    ControlToCompare property.
  • If you want to compare the Input control with a
    constant value, then set ValueToCompare property.
  • Must use the Operator property to specify the
    type of comparison to perform between Input
    control and ControlToControl or ValueToControl.

8
RegularExpressionValidator
  • You can create your own validation rules by
    building a Regular Expression.
  • Checks that the entry matches a pattern defined
    by a regular expression.
  • This type of validation enables you to check for
    predictable sequences of characters, such as
    those in e-mail addresses, telephone numbers,
    postal codes, and so on.

9
CustomValidator
  • Performs user-defined validation on an input
    control.
  • Checks the user's entry using validation logic
    that you write yourself.
  • This type of validation enables you to check for
    values derived at run time.

10
ValidationSummary
  • ValidationSummary control isused to summarize
    the error messages from validators ona web page,
    in one location.
  • You can display the summary as a list, bulleted
    list, or a single paragraph by setting the
    DisplayMode property.
  • You can display an additional messge in a alert
    by setting the ShowMessageBox property.
  • ValidationSummary control does not validate any
    input, rather, it only summarizes the errors in
    one point.

11
ValidationControls - Summary
  • RequiredFieldValidator
  • Makes sure a form field is not left blank.
  • RangeValidator
  • Makes sure a fields value falls within a given
    range.
  • CompareValidator
  • Compares a fields value with other values or
    other fields values.
  • RegularExpressionValidator
  • Evaluates data against a regular expression.
  • CustomValidator
  • Evaluates data against custom criteria.
  • ValidationSummary
  • Does not validate rather provides summary of all
    errors.

12
HomeWork
  • Do Panel exercise on page 111.
  • Do PlaceHolder exercise on page 113.
  • Create different validation controls.
Write a Comment
User Comments (0)
About PowerShow.com