E
Eugene Anthony
How do I validate an integer number using asp.net with c#?
Eugene Anthony
Eugene Anthony
You can:
1) call Int32.Parse method and catch exceptions
2) call Int32.TryParse method and check the return value
3) don't validate anything, just go ahead. You will get an exception if
something is wrong.
3) is the common choice in most of scenarios.
Some developers consider validators cumbersome and don't use them.
Some developers consider validators cumbersome and don't use them.
Looks like another "rapid vs good" kind of debate.
The custom validators are good for rapid development.
But I (as it seems Mark) has done, is created some custom and reusable
java
scripts routines.
You'll also notice that the custom validators are only the most trivial
things.
When you start working with forms with complicated rules beyond stuff like
"yes / no" or some text in a textbox, then having some better than the
custom validators makes your code better and more maintainable.