如何使关键preSS ASP文本框的事件? [英] How to make keypress event of asp textbox?

查看:130
本文介绍了如何使关键preSS ASP文本框的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我写ASP山雀TextBox控件的计算。我想正与键preSS事件做我的计算。低于code我使用,但不工作

Hi all i am writing calculation of varius asp textbox controls. I want my calculation being done with keypress event. Below code i am using but not working

.aspx页面中

<asp:TextBox ID="txtMaintCost onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

.js文件

function calculateFinanceDetail() {
            var txtMaintCost = $('input[id$=txtMaintCost]').val();
            var txtInstallCost = $('input[id$=txtInstallCost]').val();
            var txtFreightCost = $('input[id$=txtFreightCost]').val();
}

它不是调用键preSS事件JavaScript函数...
如果任何人有任何想法比请帮我在这。

its not calling javascript function on keypress event... If anyone have any idea than please help me in this..

推荐答案

缺少在文本框的ID的结束。

Missing " at the end of id of textbox.

修改

<asp:TextBox ID="txtMaintCost onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

<asp:TextBox ID="txtMaintCost" onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

尝试使用服务器控件的ClientID的。你可能没有静态IDS 的服务器端控件。您不必使用通配符,如果你有固定的ID。

Try using the ClientID of server controls. You might not having static ids for server side controls. You do not have to use wild cards if you have fixed ids.

function calculateFinanceDetail() {
      var txtMaintCost = $('input[id=<%=txtMaintCost.ClientID%>]').val();
      var txtInstallCost = $('input[id=<%=txtInstallCost.ClientID%>]').val();
      var txtFreightCost = $('input[id=<%=txtFreightCost.ClientID%>]').val();
}

这篇关于如何使关键preSS ASP文本框的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆