用Ajax插件
<asp:TextBox ID="txtWeb" runat="server" Width="195px"></asp:TextBox><cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServicePath="~/WebService.asmx"
ServiceMethod="GetHot" EnableCaching="true" MinimumPrefixLength="1" CompletionSetCount="10"
TargetControlID="txtWeb">
</cc1:AutoCompleteExtender>
---------------方法
public static string[] GetHot(string keyword, int count)
{
IList<string> results = new List<string>(count);
string sql = "select top 10 * from Email_Msg where websiteid like '%" + keyword + "%' order by id";
IList<Email_Msg> list = GetSearchKeywordBySql(sql);
foreach (Email_Msg item in list)
{
results.Add(item.Websiteid);
}
return results.ToArray();
}
写出来的效果,不够理想,想更进一步的实现谷歌的功能,如果输入多个字符,可以更进一步的实现效果。达到精确。