try
{
  int.Parse(Request["id"].ToString());
  string str = "this a number";
}
catch
{
  错误处理
}

解决方案 »

  1.   

    for(int i=0;i<objectid.Length ;i++)
    {
    switch(objectid[i])
    {
    case "0":
    case "1":
    case "2":
    case "3":
    case  "4":
    case "5":
    case"6":
    case"7":
    case"8":
    case"9":
    case"0":
    continue;
    break;
    efault:
    //出错 }
    }
      

  2.   

    default:
        //出错
    ojbectid 为Request["id"].ToString()
      

  3.   

    用正则表达式判断,可以写个函数
    Public Function IsNum(ByVal aaa As String) As Boolean
            Dim i As Regex = New Regex("^\d+$")    
            If i.IsMatch(aaa ) = True Then
                Return True
            End If
            Return False
    End Functionif isNum(id)= True Then
       显示这个新闻
    else
       如果不是数值类型就弹出框提示
    endif
      

  4.   

    正则表达式是try语句处理速度的20倍