日期:2014-05-18 浏览次数:20490 次
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function calc()
{
if(document.getElementById("TextBox1").value != "" && document.getElementById("TextBox2").value != "")
document.getElementById("TextBox3").value = parseFloat(document.getElementById("TextBox1").value) + parseFloat(document.getElementById("TextBox2").value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" onblur="calc()"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onblur="calc()"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
------解决方案--------------------
用js脚本,在ONBLUR事件中,将需要求和的两个textbox中的值转换为数字类型,在进行相加
将加的结果赋给textbox就可以了