加入對js文件的ScriptManager
參考用下面的腳本,並使用Suggest
或None
模式對於組合
Sys.Application.add_load(function() {
Sys.Extended.UI.ComboBox.prototype._ensureHighlightedIndex = function() {
// highlight an index according to textbox value
var textBoxValue = this.get_textBoxControl().value;
// first, check the current highlighted index
if (this._highlightedIndex != null && this._highlightedIndex >= 0
&& this._isExactMatch(this._optionListItems[this._highlightedIndex].text, textBoxValue)) {
return;
}
// need to find the correct index
var firstMatch = -1;
var ensured = false;
var children = this.get_optionListControl().childNodes;
for (var i = 0; i < this._optionListItems.length; i++) {
var itemText = this._optionListItems[i].text;
children[i].style.display = this._isPrefixMatch(itemText, textBoxValue) ? "list-item" : "none";
if (!ensured && this._isExactMatch(itemText, textBoxValue)) {
this._highlightListItem(i, true);
ensured = true;
}
// if in DropDownList mode, save first match.
else if (!ensured && firstMatch < 0 && this._highlightSuggestedItem) {
if (this._isPrefixMatch(itemText, textBoxValue)) {
firstMatch = i;
}
}
}
if (!ensured) {
this._highlightListItem(firstMatch, true);
}
};
});
AutoCompleteExtender在這種情況下,所有的方式組合框更好的選擇將呈現頁面
上的所有項目,您應該使用'自動完成Externder'爲,而不是'Combobox'。 – yogi
@ yogi:我只能使用ajax。:( –
是的,Ajax Toolkit中有一個'AutoComplete Extener'轉到這裏:http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx – yogi