0% found this document useful (0 votes)
5 views32 pages

IT 10-Data Validation

Data validation involves checking the accuracy and quality of source data before processing it, serving as a form of data cleansing. ASP.NET provides various validation controls, including RequiredFieldValidator, RangeValidator, and CompareValidator, which ensure user input data is valid and prevent the storage of invalid data. The BaseValidator class serves as a foundation for these controls, offering common properties and methods for validation tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views32 pages

IT 10-Data Validation

Data validation involves checking the accuracy and quality of source data before processing it, serving as a form of data cleansing. ASP.NET provides various validation controls, including RequiredFieldValidator, RangeValidator, and CompareValidator, which ensure user input data is valid and prevent the storage of invalid data. The BaseValidator class serves as a foundation for these controls, offering common properties and methods for validation tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

DATA VALIDATION

SLIDESMANIA.C
Data
Validation
SLIDESMANIA.C
Data
Validation
●Data validation means checking the accuracy and
quality of source data before using, importing or
otherwise processing data.

●Data validation is a form of data cleansing.


SLIDESMANIA.C
Data
Validation
Controls
SLIDESMANIA.C
Data Validation
Controls
●ASP.NET validation controls validate the user input
data to ensure that useless, unauthenticated, or
contradictory data don't get stored.
SLIDESMANIA.C
Data Validation
Controls
ASP.NET provides the following validation controls:

●RequiredFieldValidator
●RangeValidator
●CompareValidator
●RegularExpressionValidator
●CustomValidator
●ValidationSummary
SLIDESMANIA.C
BaseValidato
r Class
SLIDESMANIA.C
BaseValidator
Class
● The validation control classes are inherited from the
BaseValidator class hence they inherit its properties
and methods.

● therefore, it would help to take a look at the


properties and the methods of this base class, which
are common for all the validation controls:
SLIDESMANIA.C
BaseValidator
Class
Members Description
ControlToValidate Indicates the input control to validate.
Display Indicates how the error message is shown.
EnableClientScript Indicates whether client side validation will take.
Enabled Enables or disables the validator.
ErrorMessage Indicates error string.
Text Error text to be shown if validation fails.
IsValid Indicates whether the value of the control is valid.
SLIDESMANIA.C
BaseValidator
Class
SetFocusOnError It indicates whether in case of an invalid control, the focus
should switch to the related input control.
ValidationGroup The logical group of multiple validators, where this control
belongs.
Validate() This method revalidates the control and updates the IsValid
property.
SLIDESMANIA.C
RequiredFie
ldValidator
Control
SLIDESMANIA.C
RequiredFieldValidator
Control
● The RequiredFieldValidator control ensures that
the required field is not empty. It is generally tied to a
text box to force input into the text box.

● The syntax of the control is as given:


SLIDESMANIA.C
RequiredFieldValidator
Control
SLIDESMANIA.C
RangeValidat
or Control
SLIDESMANIA.C
RangeValidator
Control
● The RangeValidator control verifies that the input
value falls within a predetermined range.

● It has three specific properties:


SLIDESMANIA.C
RangeValidator
Control

Properties Description
Type It defines the type of the data. The available values are:
Currency, Date, Double, Integer, and String.
MinimumValue It specifies the minimum value of the range.
MaximumValue It specifies the maximum value of the range.
SLIDESMANIA.C
RangeValidator
Control
SLIDESMANIA.C
CompareValidat
or Control
SLIDESMANIA.C
CompareValidator
Control
● The CompareValidator control compares a value in
one control with a fixed value or a value in another
control.

● It has the following specific properties:


SLIDESMANIA.C
CompareValidator
Control
Properties Description
Type It specifies the data type.
ControlToCompare It specifies the value of the input control to compare with.

ValueToCompare It specifies the constant value to compare with.


Operator It specifies the comparison operator, the available values
are: Equal, NotEqual, GreaterThan, GreaterThanEqual,
LessThan, LessThanEqual, and DataTypeCheck.
SLIDESMANIA.C
CompareValidator
Control
SLIDESMANIA.C
RegularExpress
ionValidator
SLIDESMANIA.C
RegularExpressionValid
ator
● The RegularExpressionValidator allows validating
the input text by matching against a pattern of a
regular expression. The regular expression is set in
the ValidationExpression property.

● The following table summarizes the commonly used


syntax constructs for regular expressions:
SLIDESMANIA.C
RegularExpressionValida
tor
SLIDESMANIA.C
RegularExpressionValida
tor
SLIDESMANIA.C
CustomValidato
r
SLIDESMANIA.C
CustomValidat
or
● The CustomValidator control allows writing
application specific custom validation routines for
both the client side and the server side validation.

● The client side validation is accomplished through the


ClientValidationFunction property. The client side
validation routine should be written in a scripting
language, such as JavaScript or VBScript, which the
SLIDESMANIA.C

browser can understand.


SLIDESMANIA.C
ValidationSumma
ry
SLIDESMANIA.C
ValidationSumma
ry
● The ValidationSummary control does not perform
any validation but shows a summary of all errors in
the page.

● A ValidationSummary control can display validation


errors in the page itself, or it can display validation
errors in a separate message box.
SLIDESMANIA.C

● A ValidationSummary control is helpful when we want


ValidationSumma
ry
The following two mutually inclusive properties list out
the error message:

● ShowSummary : shows the error messages in


specified format.

● ShowMessageBox : shows the error messages in a


separate window.
SLIDESMANIA.C
<asp:ValidationSummary ID="ValidationSummary1"
runat="server" DisplayMode = "BulletList" ShowSummary =
"true" HeaderText="Errors:" />
SLIDESMANIA.C

You might also like