IsNumeric and IsAlpha

  • Thread starter Thread starter yossimotro
  • Start date Start date
Y

yossimotro

Hi,

I'm using C# to write my ASP.NET code.
Is there anyway of using the above functions with C#?

Thanks,
Yossi.
 
Some litte hint of what those functions should do would be helpful...

This might be what you are looking for, or not at all...

You can add a reference to Microsoft.VisualBasic.dll to use the
Microsoft.VisualBasic.Information.IsNumeric method.

You can use Char.IsLetter(char) to check if a character is an alphabetic
letter.
 
Hi,

I need to validate data from textboxes before I add them to the sql
query.
I think adding a reference to VisualBasic is too comlicated, not that
it is hard but it just doesn't seem right.
Also is there a function to validate a date?

Thanks,
Yossi.
 
That's better. It so much easier to help someone who is telling the
purpose of the question instead of just asking for how to do it the way
he/she thinks that it is done. :)

The best validation for numeric values and dates is to actually try to
convert them. Use DateTime.TryParse and Int32.TryParse methods for
instance. If you use a parameterized query (which you really should),
you would want them converted anyway.

To validate string data you can use RegEx. To verify that a string only
contains alphabetic characters you use RegEx.IsMatch(theString,
"^[A-Za-z]$").
 
Hi,

Try using Regular Expression Validators. This will allow you to
validate any kind of data. Numeric and Alpha are simple regex
expressions which you will be able to find easily by searching on
google (that is if you cannot figue out how to write them on your own
from the MSDN documentation provided on them).

Regards,
Vaibhav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top