Any Function for testing a int Type? (.net)

  • Thread starter Thread starter fatboycanteen
  • Start date Start date
F

fatboycanteen

I have a texbox
when user enter a value
and submit
I want to check the input value is integer or not
any method provide asp.net! (vb language)
Thank You
 
fatboycanteen said:
I have a texbox
when user enter a value
and submit
I want to check the input value is integer or not
any method provide asp.net! (vb language)
Thank You

Use a CompareValidator:
- set the ControlToValidate property to the textbox you want to validate
- set the Operator property to DataTypeCheck
- set the Type property to Integer
- don't forget to set the ErrorMessage text

Note 1: an empty textbox still satisfies the CompareValidator (add a
RequiredFieldValidator to prevent this)
Note 2: the value returned from the textbox is still a "text", so you need
an Int32.Parse() to convert to a real integer

Hans Kesting
 
-----Original Message-----



Use a CompareValidator:
- set the ControlToValidate property to the textbox you want to validate
- set the Operator property to DataTypeCheck
- set the Type property to Integer
- don't forget to set the ErrorMessage text

Note 1: an empty textbox still satisfies the CompareValidator (add a
RequiredFieldValidator to prevent this)
Note 2: the value returned from the textbox is still a "text", so you need
an Int32.Parse() to convert to a real integer

Hans Kesting


.
 
Back
Top