方法一:
代碼如下:
int i=0;
if (!int.TryParse(this.txtPage.Text, out i))
{
Response.Write("<script>alert('請(qǐng)輸入有效數(shù)字!')</script>");
this.txtPage.Text = string.Empty;
}//判斷是否是數(shù)字
方法二:
代碼如下:
try
{
if (Convert.ToInt32(this.txtPage.Text) > totalPage || Convert.ToInt32(this.txtPage.Text)<1)
{
ClientScript.RegisterClientScriptBlock(GetType(), "提示", "alert('請(qǐng)輸入有效數(shù)字!')", true);
}
else
{
ViewState["pageindex"] = this.txtPage.Text;
GetData();
}
}
catch (Exception)
{
ClientScript.RegisterClientScriptBlock(GetType(), "提示", "alert('請(qǐng)輸入有效數(shù)字!')", true);
}
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com