当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET(C#)验证数字

ASP.NET(C#)验证数字

2019年04月19日  | 移动技术网IT编程  | 我要评论

115账号,皇上娘娘要爬墙,邹奇奇

方法一:
int i=0;
if (!int.tryparse(this.txtpage.text, out i))
{
   response.write("<script>alert('请输入有效数字!')</script>");
   this.txtpage.text = string.empty;
 }//判断是否是数字
方法二:
try
        {

            if (convert.toint32(this.txtpage.text) > totalpage || convert.toint32(this.txtpage.text)<1)
            {
                clientscript.registerclientscriptblock(gettype(), "提示", "alert('请输入有效数字!')", true);
            }
            else
            {
              viewstate["pageindex"] = this.txtpage.text;
              getdata();
            }
        }
        catch (exception)
        {
           clientscript.registerclientscriptblock(gettype(), "提示", "alert('请输入有效数字!')", true);
        }

 


摘自 淡蓝蓝蓝

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网