IsNumeric Method issue

I created a method in my class which will determine if an input is a numeric value or not.


public static Boolean IsNumeric(string strInput)
{
        try
        {
            int iInput = int.Parse(strInput);
            return true;
        }
        catch
        {
            return false;
        }
        
}

And I used it in my customvalidator control like this


if (txtLateAllowance.Text.Length == 0)
{
            vLateAllowance.Text = "Please specify the late allowance entry of employee.";
            args.IsValid = false;
            return;
        }
        else
        {   
            vLateAllowance.Text = "Invalid entry.";
            args.IsValid = false;
            return;
        }

And even I input a numeric value in my entry, still I get the error message “Invalid entry”. Can anyone from this community have an idea on how am I going to solve this issue. Thanks

And there is int.TryParse method that does exactly what you did.

Where??

Or even the IsNumeric function in the Microsoft.VisualBasic Namespace.

Yes, where are you using it? all I see is

        else
        {   
            vLateAllowance.Text = "Invalid entry.";

Edit: Also, have you considered using a RangeValidator?