ASP.NETプロジェクト用のコンボボックスが必要なので、Ajax Control Toolkitコンボボックス(http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx)を使用することにしました。
ページをリロードしたくないのでポストバックを使用したくありませんが、サーバーに呼び出して新しいリストアイテムを永続化できるように、テキストボックスのテキストがいつ変更されるかを知る必要があります。
onchange
このコンボボックスが使用する入力ボックスにoronblur
イベントをバインドする方法に興味があります。
これは私の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")はnullです
[このエラーを中断します]
$ find('PlantDropDown')。add_propertyChanged(function(sender、e){\ r \ n
私はJavascript側にjQueryを使用していますが、それが役立つ場合に備えて。
最終更新:
crescentfreshの助けを借りて動作するようになり、最後に.aspxファイルにこれが含まれています。
<input type="hidden" id="PlantDropDownID" value="<%= PlantDropDown.ClientID %>" />
そして、これは私の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;
}
})