我需要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