<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"
AsyncPostBackErrorMessage="出错了" AsyncPostBackTimeout="2">
</asp:ScriptManager>
<asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServicePath="~/WebService.asmx"
ServiceMethod="getstring"
TargetControlID="txtTest"
CompletionInterval="500"
CompletionSetCount="10"
MinimumPrefixLength="1"
>
</asp:AutoCompleteExtender>
</div>
</form>
</body>
</html>web servicesusing System.Web.Services;
using System.Data;
using System.Web.Script.Services;/// <summary>
///WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
public WebService () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string[] getstring(string prefixText, int count)
{
Operation op=new Operation();
DataTable da=op.Seach("Dic_wuzi_guanli_bianma",null,new string[]{"top("+count+") [name]"},new string[]{"[name] like '"+prefixText+"%'"});
if (da.Rows.Count > 0)
{
string[] aa = new string[da.Rows.Count];
for (int i = 0; i < da.Rows.Count; i++)
{
aa[i] = da.Rows[i]["name"].ToString();
}
return aa;
}
else
{
return new string[]{""}
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货