Upload
amberlynn-george
View
229
Download
0
Tags:
Embed Size (px)
Citation preview
www.acropetal.com
Vijayalakshmi G M
Validation ControlsValidation Controls
ContentsASP.Net Validation Controls OverviewTypes of Validation Controls
ASP.Net Validation Controls - Introduction
Validation Controls - Introduction Validates User input data. It can test for
Missing valuesComparison valuesValues within a range
Ensures that proper data is supplied to processing scripts.
Associated with TextBox control. Automatically performance the test when the
Button, LinkButton, or ImageButton controls are clicked.
Validation ControlsWhen the validation test fails it displays the
error message to the user.User can reenter the value in the text box.
ASP.Net Validation Controls
1. RequiredFieldValidator2. RangeValidator3. CompareValidator4. RegularExpressionValidator5. CustomValidator6. ValidationSummary
ASP.Net Validation Controls
<asp:RequiredFieldValidator> Control Tests the textbox for the missing value and displays
an error message when value is not found Used to Check the Mandatory Fields in the Web
Forms. General format
<asp:RequiredFieldValidator> - Properties
Property Description
ControlToValidate Gives the id of the textbox to be validated.
ErrorMessage It provides text for the error message.
SetFocusOnErrorMessage
Places the cursor in the associated text box.
ValidationGroup Identifies a grouping of TextBox controls to which a set of validation tests applies
<asp:RequiredFieldValidator>
Note:It occupies horizontal space on the page equal to
the length of the error message. The space is preallocated to display the messages.When Display=“Dynamic” property is set the
message space is not preallocated and it will be dynamically set.
<asp:RequiredFieldValidator>
<asp:RangeValidator> Control Tests the value within the range of the value. Values data types
1. Currency (with a dollar sign and commas)2. Date3. Double (floating-point)4. Integer5. String (default).
RangeValidator – General Format
RangeValidator - Properties
1. ControlToValidate 2. ErrorMessage 3. SetFocusOnErrorMessage 4. ValidationGroup Note: Same as RequiredFieldValidator Control1. Type – It specifies the data type.2. MinimumValue – Sets the minimum value 3. MaximumValue – Sets the Maximum value
RangeValidator
<asp:CompareValidator> Compares the given value against a predefined value
based on the comparison operation selected by the user.
The test can be made for the values with following data types.1. Currency (with a dollar sign and commas)2. Date3. Double (floating-point)4. Integer5. String (default).
<asp:CompareValidator>
<asp:CompareValidator>
Property DescriptionOperator Sets the comparison operator.
Value To Compare
It is used to set the target value to be tested.
<asp:CompareValidator>
<asp:CustomValidator> Control This control is used to perform the
additional test (Which cannot performed when used in combinations).
General Format
<asp:CustomValidator> - Properties Basic properties are similar to the
RequiredFieldValidator Control.
Property DescriptionIsValid Set to false to indicate the failure of
the Validation TestOnServerValidate
It calls a subprogram to perform explicitly coded tests. The called subprogram takes the special ServerValidateEventArgs argument.
<asp:CustomValidator> - Properties
Regular Expression Validator
Used to validate complex expressions.The expressions can be
phone numberemail addresszip code and many more.
Set the ValidationExpression property to any type of expression OR
Create the custom expression to validate the data.
Regular Expression Validator
Regular Expression Validator
<asp:ValidationSummary>
The individual error messages generated by separate controls can be displayed together.
It can limit its error reporting to an identified set of grouped controls.
<asp:ValidationSummary> General Format
Example
<asp:ValidationSummary>
DisplayMode – Sets the display mode for the of the error summary.
ShowMessageBox – Display the error messages in the form of a message box.
ShowSummary – It suppresses the display of the error message on the page.
<asp:ValidationSummary>
Resource
Resources
ASP.Net Validation Controlshttp://quickstarts.asp.net/QuickStartv20/aspnet/
doc/ctrlref/validation/validationsummary.aspxhttp://devhood.com/Tutorials/tutorial_details.asp
x?tutorial_id=46http://msdn.microsoft.com/en-us/library/aa4790
45.aspx
Thank You