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: //出错 } }
default: //出错 ojbectid 为Request["id"].ToString()
用正则表达式判断,可以写个函数 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
{
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:
//出错 }
}
//出错
ojbectid 为Request["id"].ToString()
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