ajax里绑定框,当文本框更改时,如何将javascript事件处理程序绑定到Ajax Control Toolkit组合框...

我不想使用回发,因为我不想重新加载页面,但我需要知道文本框中的文本何时更改,以便我可以调用服务器来保留新的列表项.

我很好奇如何将onchange或onblur事件绑定到此组合框使用的输入框.

这是我的asp.net页面:

AutoCompleteMode="SuggestAppend"

ItemInsertLocation="OrdinalText" AutoPostBack="false">

更新:我尝试使用该建议,我收到此错误:

$find("PlantDropDown") is null

[Break on this error] $find('PlantDropDown').add_propertyChanged(function(sender, e) {\r\n

我在javascript方面使用jQuery,顺便说一句,如果有帮助的话.

最后更新:

我得到了它的工作,感谢crescentfresh的帮助,最后我在我的.aspx文件中有这个:

这是在我的javascript文件中,因为我不在我的.aspx文件中推送javascript:

elem = document.getElementById('PlantDropDownID');

$find(elem.value).add_propertyChanged(function(sender, e) {

if (e.get_propertyName() == 'selectedIndex') {

var newValue = sender.get_textBoxControl().value;

}

})

解决方法:

我相信你应该绑定到“propertyChanged”事件并检查“selectedIndex”属性的更改:

$find('PlantDropDown').add_propertyChanged(function(sender, e) {

if (e.get_propertyName() == 'selectedIndex') {

var newValue = sender.get_textBoxControl().value;

// persist selected value here...

}

})

api并不容易,这是肯定的.例如,没有.get_value()方法,这将是很好的,而不必通过嵌入的文本框控件.

编辑:

&GT $find(“PlantDropDown”)为空

确保使用正确的ID.请参阅.NET control ids in the client.要获得参考,您可能需要执行以下操作:

$find('')

&GT我在javascript方面使用jQuery

这没有任何意义.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值