使用下面的脚本添加到ScriptManager
js 文件的引用中,并使用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 是更好的选择,因为 ComboBox 将呈现页面上的所有项目