CopyCode The 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. asmxCopy codeThe Code is as follows: <% @ WebService Language = "C #" codebehind = "~ /App_code/autocomplete. cs "class =" AutoComplete "%>
AutoComplete. CSCopy 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;
}
}