在WebForms和MVC中实现AutoComplete
2012-05-14 13:48:45 来源:WEB开发网核心提示: 代码如下 <asp:TextBox ID="txtLearnCenter" runat="server" Width="188px"></asp:TextBox> <cc1:AutoCom
代码如下
<asp:TextBox ID="txtLearnCenter" runat="server" Width="188px"></asp:TextBox> <cc1:AutoCompleteExtender ID="txtLearnCenter_AutoCompleteExtender" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="~/WebService/PymService.asmx" ServiceMethod="GetLearnCenterByPym" MinimumPrefixLength="1" CompletionSetCount="15" TargetControlID="txtLearnCenter" CompletionListHighlightedItemCssClass="autocomplete_highlightedlistitem" CompletionListCssClass="autocomplete_completionlistelement" CompletionListItemCssClass="autocomplete_listitem"> </cc1:AutoCompleteExtender>
具体的属性是什么意思,大家自己看看就明白了。我只介绍这个ServicePath和ServiceMethod,ServicePath就是web服务地址,可以相对或者绝对,ServiceMethod就是web服务提供的方法。
public class PymService : System.Web.Services.WebService { [WebMethod] public string[] GetProfessionalByPym(string prefixText, int count) { return new Common().GetProfessionalNameByPym(prefixText, count); } [WebMethod] public string[] GetLearnCenterByPym(string prefixText, int count) { return new Common().GetLearnCenterByPym(prefixText, count); } [WebMethod] public string[] GetStudentNameByPym(string prefixText, int count) { return new Common().GetStuNameByPym(prefixText, count); } }
更多精彩
赞助商链接