52,782
社区成员
发帖
与我相关
我的任务
分享
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class ProductAutoComplete : System.Web.Services.WebService {
public ProductAutoComplete () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
[ScriptMethod]
public string[] GetProductName(string prefixText, int count)
{
List<string> suggestions = new List<string>(count);
SQL sql = new SQL();
suggestions = sql.getSearchProduct(prefixText);
return suggestions.ToArray();
}
}
<asp:TextBox ID="TextBox1" runat="server" Width="410px" AutoPostBack="False" />
<cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
TargetControlID="TextBox1" ServiceMethod="GetProductName" ServicePath="~/App_Code/ProductAutoComplete.cs" MinimumPrefixLength="1" Enabled="True">
</cc1:AutoCompleteExtender>