【发布时间】:2019-06-13 00:59:40
【问题描述】:
我不明白我的代码有什么问题。 很基础,但还是有错误。
在标题标签中我有以下脚本,你可以跳过最后一个函数,这是我这个问题需要的:
<script type="text/javascript">
function allowOnlyNumber(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
return false;
return true;
}
function checkboxalert() {
var active = document.getElementById("chkActive").checked;
var inactive = document.getElementById("chkInactive").checked;
if ((!active) && (!inactive)) alert("Please ensure that either Active or Inactive is checked before limiting search, otherwise, Active records will be assumed...")
}
function lostfocusLowPrice() {
if (getElementById("txtFindHighPrice").value = "" && getElementById("txtFindLowPrice").Value != "") getElementById("txtFindLowPrice").Value = getElementById("txtFindLowPrice").Value;
}
</script>
在我的网页设计中,我有这个:
<asp:TextBox ID="txtFindLowPrice" OnTextChanged="lostfocusLowPrice()" onkeypress="return allowOnlyNumber(event)" runat="server" Height="22px" Width="63px"></asp:TextBox>
我得到一个编译错误:
描述:在编译服务此请求所需的资源期间发生错误。请查看以下特定错误详细信息并适当修改您的源代码。
编译器错误消息:CS1061:“webform1_aspx”不包含“lostfocusLowPrice”的定义,并且找不到接受“webform1_aspx”类型的第一个参数的扩展方法“lostfocusLowPrice”(您是否缺少 using 指令或程序集参考?)
拼写匹配。代码非常基础。无法想象它可能是什么。其他 javascript 函数工作正常。
有什么想法吗?
【问题讨论】:
-
Aamath 在下面有一个很好的答案,但是对于我想要做的事情有没有客户端解决方案?
标签: c# asp.net textbox lost-focus