Copy codeThe Code is as follows:
<Asp: TextBox ID = "txtTempScenic" runat = "server"> </asp: TextBox>
<Ajax: AutoCompleteExtender ID = "txtTempScenic_AutoCompleteExtender" runat = "server" BehaviorID = "AutoCompleteEx" DelimiterCharacters = "" Enabled = "True" ServicePath = "~ /WebService/AutoComplete. asmx "ServiceMethod =" GetScenic "TargetControlID =" register "CompletionInterval =" 500 "CompletionSetCount =" 20 "EnableCaching =" true "MinimumPrefixLength =" 1 "> </ajax: AutoCompleteExtender>
AutoComplete. asmx
Copy codeThe Code is as follows:
<% @ WebService Language = "C #" CodeBehind = "~ /App_Code/AutoComplete. cs "Class =" AutoComplete "%>
AutoComplete. cs
Copy codeThe Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. Services;
Using System. Data;
/// <Summary>
/// Add by ahuinan
/// </Summary>
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = WsiProfiles. BasicProfile1_1)]
// To allow ASP. net ajax to call this Web service from a script, cancel the comments to the downstream.
[System. Web. Script. Services. ScriptService]
Public class AutoComplete: System. Web. Services. WebService
{
Public AutoComplete ()
{
// If you use the designed component, uncomment the following line
// InitializeComponent ();
}
[WebMethod]
Public string HelloWorld ()
{
Return "Hello World ";
}
// Obtain the Scenic Spot
[WebMethod]
Public string [] GetScenic (string prefixText, int count)
{
ET_ERP.BLL.ERP_ScenicArea B _ScenicArea = new ET_ERP.BLL.ERP_ScenicArea ();
String strWhere = "SA_Name like '" + prefixText + "%' AND SA_IsDel = 0 ";
DataSet ds = B _ScenicArea.Select ("top" + count + "SA_Name", strWhere );
Count = ds. Tables [0]. Rows. Count;
String [] array = new string [count];
For (int I = 0; I <count; I ++)
{
Array [I] = ds. Tables [0]. Rows [I] ["SA_Name"]. ToString ();
}
Return array;
}
}