Copy Code code 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= "Txttempscenic" completioninterval= "completionsetcount=" enablecaching= "true" Minimumprefixlength= "1" ></ajax:AutoCompleteExtender>
Autocomplete.asmx
Copy Code code as follows:
<%@ WebService language= "C #" codebehind= "~/app_code/autocomplete.cs" class= "AutoComplete"%>
AutoComplete.cs
Copy Code code 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 the use of ASP.net AJAX to invoke this Web service from a script, uncomment the downlink.
[System.Web.Script.Services.ScriptService]
public class AutoComplete:System.Web.Services.WebService
{
Public AutoComplete ()
{
If you are using a design component, uncomment it to follow the line
InitializeComponent ();
}
[WebMethod]
public string HelloWorld ()
{
Return to "Hello World";
}
Access to scenic spots
[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;
}
}