For C# console:
bool result = Int32.TryParse(value, out number);
if (result)
{
Console.WriteLine("Converted '{0}' to {1}.", value, number);
}
OR
C# Validating TextBox Control[
^]
For asp.net, call any of the javascript functions :
Example 1:
function is_int(value){
for (i = 0 ; i < value.length ; i++) {
if ((value.charAt(i) < '0') || (value.charAt(i) > '9')) return false
}
return true;
}
Example 2 :
function is_int(value){
return !isNaN(parseInt(value * 1)
}
Example 3:
function is_int(value){
if((parseFloat(value) == parseInt(value)) && !isNaN(value)){
return true;
} else {
return false;
}
}
I hope the above information will be helpful. If you have more concerns, please let me know.