开发者

JQuery AutoComplete with SQL

I am using JQuery on my ASP.net page and I want to know if there is a way I could use AutoComplete with SQL. To be exac开发者_JS百科t, I am doing "select" on the database, and I will have an array of string and I want to use the array with the AutoComplete to populate strings as user types. Thanks.


One of the easiest ways to get jQuery Autocomplete functionality is to use the jQuery UI control. It uses jQuery's Ajax functionality to call to a server-side function that returns an array of values.

The code to make a call to a datasource (such as SQL Server or MySQL) looks like this (from the jQueryUI documentation):

$( "#myInputBox" ).autocomplete({
            source: "search.php",
            minLength: 2,
            select: function( event, ui ) {
                log( ui.item ?
                    "Selected: " + ui.item.value + " aka " + ui.item.id :
                    "Nothing selected, input was " + this.value );
            }
        });


You probably want to create a new WCF web service that will wrap around your Stored Procedure / Dynamic query. You can then call that with JQuery autocomplete:

JQuery Autocomplete with WCF

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜