我需要ASP.NET项目的组合框,因此我决定使用Ajax Control Toolkit组合框(http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx)。当文本框发生变化时,如何将JavaScript事件处理程序绑定到Ajax Control Toolkit组合框
我不想使用回发,因为我不希望重新加载页面,但我需要知道文本框中的文本何时发生更改,以便我可以调用服务器来保留新的列表项。
我很好奇我如何将onchange或onblur事件绑定到此组合框使用的输入框。
这是我的asp.net页面:
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<cc1:ComboBox ID="PlantDropDown" runat="server" OnInit="PlantDropDown_Init" DropDownStyle="DropDown"
AutoCompleteMode="SuggestAppend"
ItemInsertLocation="OrdinalText" AutoPostBack="false">
</cc1:ComboBox>
更新:我尝试使用建议和我得到这个错误:
$find("PlantDropDown") is null
[Break on this error] $find('PlantDropDown').add_propertyChanged(function(sender, e) {\r\n
我使用jQuery的JavaScript端,顺便说一句,如果有帮助。
最后更新: 我得到它的工作多亏了crescentfresh帮助,并在最后我有这在我的.aspx文件:
<input type="hidden" id="PlantDropDownID" value="<%= PlantDropDown.ClientID %>" />
这是我的JavaScript文件,因为我不“T推的javascript在我的.aspx文件:
elem = document.getElementById('PlantDropDownID');
$find(elem.value).add_propertyChanged(function(sender, e) {
if (e.get_propertyName() == 'selectedIndex') {
var newValue = sender.get_textBoxControl().value;
}
})
谢谢,我正在测试它,希望我能早日知道它是如何工作的。 – 2009-09-22 03:36:07
不幸的是我收到了一个错误,在我的问题中提出了更新。 – 2009-09-22 13:02:56
我在回答中添加了更新。 – 2009-09-22 14:06:23