Visual Studio now has integrated support for range checking and type checking: -
Try the following: - TO CHECK THE RANGE Before checking / checking a specific range of numbers Go to the design view from the layout view. Then: -
View> Toolbar> Validation
Now drag on RangeValidator to the design page where you want to display the error message (if the user enters a range value) now click on the RangeValidator control. Right click and select properties. In the Properties window (usually open under the solution bar), select ERROR MESSAGE. Write: -
The number must be in the range.
Now select in the control to check and select your TextboxID (or record it anyway) from the drop-down list. Locate Enter yourself in the property bar and select Integer down.
A little higher you will find the maximum and minimum value. Enter your desired number.
For type checking (without any range)
Before Validating / Verifying a Specific Range of Numbers Go to the design view from the layout view. Then: -
View> Toolbar> Validation
Now drag it onto CompareValidator onto the design page where you want to display the error message (if the user enters some text into it). now click on the CompareValidator control. Right click and select properties. In the Properties window (usually open under the solution bar), select ERROR MESSAGE. Write: -
The value must be a number.
Now find the option ControltoValidate and write the name controlID in it (alternatively, you can also choose from the drop-down list). Set the Operator option and write DataTypeCheck (alternatively, you can also choose from the drop-down list) in it. Find the Type option and write Integer in it.
Sit.
Alternatively, you can write the following code on an aspx page: <% - to check without any range -%>
Prince Sharma Jul 08 '14 at 12:11 2014-07-08 12:11
source share