ASP.NET自动完成下拉列表

ASP.NET自动完成下拉列表,asp.net,jquery,autocomplete,drop-down-menu,Asp.net,Jquery,Autocomplete,Drop Down Menu,是否存在用于asp.net自动完成DropDownList的控件或Jquery插件? 如果是,请在此处链接示例。 我不想使用asp.net ajax控件工具包我不知道这是否是您想要的,但这里有一个类似于Facebook的提前键入列表: 它是一个jQuery插件,使用AJAX调用web服务以在键入时加载列表中的项目,并实现一些智能缓存以保存web服务调用。就像我说的,可能不是你想要的,但至少值得一看 还可以查看jqueryautocomplete jQuery AutoComplete可以与Dr

是否存在用于asp.net自动完成DropDownList的控件或Jquery插件? 如果是,请在此处链接示例。
我不想使用asp.net ajax控件工具包

我不知道这是否是您想要的,但这里有一个类似于Facebook的提前键入列表:

它是一个jQuery插件,使用AJAX调用web服务以在键入时加载列表中的项目,并实现一些智能缓存以保存web服务调用。就像我说的,可能不是你想要的,但至少值得一看

还可以查看jqueryautocomplete


jQuery AutoComplete可以与DropDownList一起使用

//只需将此脚本放在页面中,并调用dropdownlist中的combobox2类即可
(函数($){
$.widget(“custom.combobox2”{
_创建:函数(){
this.wrapper=$(“”)
.addClass(“自定义组合框2”)
.insertAfter(此.element);
this.element.hide();
这是。_createAutocomplete();
这是。_createShowAllButton();
},
_createAutocomplete:函数(){
var selected=this.element.children(“:selected”),
value=selected.val()?selected.text():“”;
this.input=$(“”)
.appendTo(此.wrapper)
.val(值)
.attr(“标题”、“名称”)
.addClass(“custom-combobox2-input ui小部件ui小部件内容ui状态默认ui左角”)
.自动完成({
延迟:0,
最小长度:0,
来源:$.proxy(此“\u来源”)
})
.工具提示({
tooltipClass:“ui状态突出显示”
});
此。_on(this.input{
自动完成选择:功能(事件、用户界面){
ui.item.option.selected=true;
此._触发器(“选择”,事件{
项目:ui.item.option
});
},
AutoCompleteTechange:“\u RemoveFinValid”
});
},
_createShowAllButton:函数(){
var input=this.input,
wasOpen=false;
$("")
.attr(“tabIndex”,-1)
.attr(“标题”、“显示所有项目”)
.appendTo(此.wrapper)
.按钮({
图标:{
主要:“ui-icon-triangle-1-s”
},
文本:false
})
.removeClass(“用户界面角全部”)
.addClass(“自定义-combobox2-右键切换ui”)
.mousedown(函数(){
wasOpen=input.autocomplete(“小部件”)是(“:可见”);
})
。单击(函数(){
input.focus();
//如果已经可见,请关闭
如果(打开){
返回;
}
//将空字符串作为要搜索的值传递,显示所有结果
input.autocomplete(“搜索”和“);
});
},
_来源:功能(请求、响应){
var matcher=newregexp($.ui.autocomplete.escapeRegex(request.term),“i”);
响应(this.element.children(“option”).map(函数(){
var text=$(this.text();
if(this.value&(!request.term | | matcher.test(text)))
返回{
标签:文本,
值:文本,
选项:这个
};
}));
},
_RemoveFinValid:函数(事件,ui){
//已选择项目,无需执行任何操作
if(ui.item){
返回;
}
//搜索匹配项(不区分大小写)
var value=this.input.val(),
valueLowerCase=value.toLowerCase(),
有效=错误;
this.element.children(“选项”).each(函数(){
if($(this).text().toLowerCase()==valueLowerCase){
this.selected=valid=true;
返回false;
        //just put this script in your page and call the class combobox2 in your dropdownlist  


        <script type="text/javascript">
                    (function ($) {
                        $.widget("custom.combobox2", {
                            _create: function () {
                                this.wrapper = $("<span>")
                                .addClass("custom-combobox2")
                                .insertAfter(this.element);
                                this.element.hide();
                                this._createAutocomplete();
                                this._createShowAllButton();
                            },
                            _createAutocomplete: function () {
                                var selected = this.element.children(":selected"),
                                value = selected.val() ? selected.text() : "";
                                this.input = $("<input style='width:auto;'>")
                                .appendTo(this.wrapper)
                                .val(value)
                                .attr("title", "")
                                .addClass("custom-combobox2-input ui-widget ui-widget-content ui-state-default ui-corner-left")
                                .autocomplete({
                                    delay: 0,
                                    minLength: 0,
                                    source: $.proxy(this, "_source")
                                })
                                .tooltip({
                                    tooltipClass: "ui-state-highlight"
                                });
                                this._on(this.input, {
                                    autocompleteselect: function (event, ui) {
                                        ui.item.option.selected = true;
                                        this._trigger("select", event, {
                                            item: ui.item.option
                                        });
                                    },
                                    autocompletechange: "_removeIfInvalid"
                                });
                            },
                            _createShowAllButton: function () {
                                var input = this.input,
                                wasOpen = false;
                                $("<a>")
                                .attr("tabIndex", -1)
                                .attr("title", "Show All Items")
                                .appendTo(this.wrapper)
                                .button({
                                    icons: {
                                        primary: "ui-icon-triangle-1-s"
                                    },
                                    text: false
                                })
                                .removeClass("ui-corner-all")
                                .addClass("custom-combobox2-toggle ui-corner-right")
                                .mousedown(function () {
                                    wasOpen = input.autocomplete("widget").is(":visible");
                                })
                                .click(function () {
                                    input.focus();
                                    // Close if already visible
                                    if (wasOpen) {
                                        return;
                                    }
                                    // Pass empty string as value to search for, displaying all results
                                    input.autocomplete("search", "");
                                });
                            },
                            _source: function (request, response) {
                                var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                                response(this.element.children("option").map(function () {
                                    var text = $(this).text();
                                    if (this.value && (!request.term || matcher.test(text)))
                                        return {
                                            label: text,
                                            value: text,
                                            option: this
                                        };
                                }));
                            },
                            _removeIfInvalid: function (event, ui) {
                                // Selected an item, nothing to do
                                if (ui.item) {
                                    return;
                                }
                                // Search for a match (case-insensitive)
                                var value = this.input.val(),
                                valueLowerCase = value.toLowerCase(),
                                valid = false;
                                this.element.children("option").each(function () {
                                    if ($(this).text().toLowerCase() === valueLowerCase) {
                                        this.selected = valid = true;
                                        return false;
                                    }
                                });
                                // Found a match, nothing to do
                                if (valid) {
                                    return;
                                }
                                // Remove invalid value
                                this.input
                                .val("")
                                .attr("title", value + " didn't match any item")
                                .tooltip("open");
                                this.element.val("");
                                this._delay(function () {
                                    this.input.tooltip("close").attr("title", "");
                                }, 2500);
                                this.input.data("ui-autocomplete").term = "";
                            },
                            _destroy: function () {
                                this.wrapper.remove();
                                this.element.show();
                            }
                        });
                    })(jQuery);
                    $(function () {
                        $(".combobox2").combobox2();
                        $(".combobox2").combobox2({
                            select: function (event, ui) {
                                var f = document.getElementById("<%=form1.ClientID%>");
                                    f.submit();
                                }
                            });
                        });
                </script>


<asp:DropDownList ID="DDL_Groups4_Assign" runat="server" AppendDataBoundItems="True" AutoPostBack="True" CausesValidation="True" OnSelectedIndexChanged="DDL_Groups4_Assign_SelectedIndexChanged" Width="250px" CssClass="combobox2">
          <asp:ListItem Selected="True">Select</asp:ListItem>
                                            </asp:DropDownList>