发布于 2016-05-29 01:58:06 | 83 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


ASp.net文本计算,文本框数字输入检测,文本框的TextChanged事件,同时在属性的Auto Post Back设置为True

protected void txtQty_TextChanged(object sender, EventArgs e) 
{ 
checkForm(); 
} 
//检验文本信息是否合法,如果合法则开始计算 
protected void checkForm() 
{ 
try 
{ 
if (!IsNumberic(txtQty.Text) && txtQty.Text != "") 
{ 
checkbool = false; 
Response.Write("<script>alert('数量只能为数字,请输入数字信息,谢谢合作!')</script>"); 
txtQty.Text = ""; 
txtQty.Focus(); 
} 
else if (txtQty.Text != "") 
{ 
Qty = int.Parse(txtQty.Text); 
} 
if (!IsNumberic(txtVat.Text) && txtVat.Text != "") 
{ 
Response.Write("<script>alert('税额只能是数字,请输入数字信息,谢谢合作!')</script>"); 
checkbool = false; 
txtVat.Text = ""; 
txtVat.Focus(); 
} 
else if (txtVat.Text != "") 
{ 
Vat = Double.Parse(txtVat.Text); 
} 
if (!IsNumberic(txtUnitPrice.Text) && txtUnitPrice.Text != "") 
{ 
Response.Write("<script>alert('价格只能是数字,请输入数字信息,谢谢合作!')</script>"); 
checkbool = false; 
txtUnitPrice.Text = ""; 
txtUnitPrice.Focus(); 
} 
else if (txtUnitPrice.Text != "") 
{ 
UnitPrice = Double.Parse(txtUnitPrice.Text); 
} 
if (checkbool == true) 
{ 
if (Vat != 0 && ExVatAmount != 0) 
{ 
AmountVat = ExVatAmount / (1 - Vat / 100); 
txtAmountVat.Text = AmountVat.ToString(); 
} 
} 
} 
catch (Exception ex) 
{ 
Console.WriteLine(ex.Message); 
} 
} 
/// <summary> 
/// 名称:IsNumberic 
/// 功能:判断输入的是否是数字 
/// 参数:string oText:源文本 
/// 返回值: bool true:是 false:否 
/// </summary> 
public bool IsNumberic(string oText) 
{ 
try 
{ 
//从字符串到双精度值的转换,字符串转换为Double,如果成功则返回为真,否则返回为假。 
Double var1 = Convert.ToDouble(oText); 
return true; 
} 
catch 
{ 
return false; 
} 
} 
} 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务