Edi Wang

.NET and Azure Developer

AutoComplete

JQuery文本框自动完成,通过AJAX调用ASP.NET WebService

最近在搞博客搜索框的自动完成功能,用的是JQuery UI里的autocomplete插件。插件的数据源是用AJAX调用一个WebService,网站后台有个标签库,WebService返回的是符合条件的标签。最终效果如下: 我们先来看WebService的代码,方法很简单: [WebMethod] public List GetAllTagsForAutoComplete(string tagName) { return optTag.GetModelList().Where(p => p.Name.ToLower().StartsWith(tagName.ToLower())).ToList(); }  这个方法的作用是根据输入的内容,检索所有以tagName开头的标签。我没有返回全部标签,是因为autocomplete插件的默认行为不符合我的需求。在默认情况下,如果我输入 …
AJAX ASP.NET AutoComplete jQuery WebService