My Profile

Thursday, February 10, 2011

ASP.Net-RequiredFieldValidator & RangeValidator


Let’s see one by one control in detail:

1.    RequiredfieldValidator:
·       Used to check for null values and it is the only control which can check null values.
·       Properties:
ControlToValidate   :   <ControlName>

ErrorMessage          :    Message to be displayed when        error occurs.

 Text                          :     Same like error message but differs when   ValidationSummary Control is used.

 SetFocusOnError     :     true/false  [Automatically sets the cursor to failed validation control]

Note: Above properties are used for RequiredfieldValidator and also they are common properties for every Validation Control.

Example: 

Place a TextBox or any control and also place RequiredFieldValidator control beside it and set the above properties and test how it works.

2.    RangeValidator:
·       Used to check for range of values. It is suitable for numeric and date type of data.
·       Properties:
 MinimumValue       :        <some value> [inclusive of this value]
 MaximumValue       :        ------------
 Type                         :        Integer/Date/……

Note: we cannot use validations for all the controls. For example, we cannot use any validation for “CheckBox” because it has only 2 options checked or unchecked.

Before going to see remaining validation control, we have to see one most important property “Display”, which is also a common property to all the validation controls.

Display:
It is an enumerated property which has the following values:
·       Static
·       Dynamic
·       None

This property is related to position of validation control or Message that is to be displayed. By default, it is Static, which means the place to display Error Message will be reserved. Dynamic means Error Message place will not be reserved and only when error occurs it will create the place and display error message. None means no display of error message.
In the next post we’ll see few more validation controls…

 
---------------------------------------------------------- 
** If you like this post please like our page in 
facebook " Dot Net Support"

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More