The autocompleteextender control, fixed name setting, can help the Textbox Control to automatically input, such as http://dict.yodao.com/effect.
Attributes of the autocompleteextender control:
1. targetcontrolid: ID of the control that will be automatically input by the secondary node. The control can only be textbox;
2. servicepath: indicates the path of the web service that provides the service. If this parameter is not specified, servicemethod indicates the method name on the page;
3. servicemethod: indicates the method name for providing the service;
4. minimumprefixlength: specifies the minimum number of characters that the Textbox Control should have when the prompt service is provided. The default value is 3;
5. completionsetcount: Number of displayed items. The default value is 10;
6. enablecaching: whether to cache data on the client. The default value is true;
7. completioninterval: the time interval for reading data from the server. The default value is 1000. Unit: milliseconds.
ASPX pageCode:
< Body >
< Form ID = "Form1" Runat = "Server" >
< ASP: scriptmanager Runat = "Server" ID = "Scriptmanager1" />
< Ajaxtoolkit: autocompleteextender
ID = "Autocompleteextender1"
Runat = "Server"
Servicepath = "Autocomplete. asmx"
Targetcontrolid = "Textbox1"
Servicemethod = "Gettextstring" >
</ Ajaxtoolkit: autocompleteextender >
< ASP: textbox ID = "Textbox1" Runat = "Server" > </ ASP: textbox >
</ Form >
</ Body >
WebServcie-AutoComplete.cs code:
Using System;
Using System. Web;
Using System. collections;
Using System. Web. Services;
Using System. Web. Services. Protocols;
[WebService (namespace = " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
[System. Web. Script. Services. scriptservice]
Public Class AutoComplete: system. Web. Services. WebService {
Public AutoComplete () {
}
[Webmethod]
Public String [] Gettextstring ( String Prefixtext, Int Count)
{
String [] Strarray = New String [Count];
For ( Int I = 0 ; I < Count; I ++ )
{
Strarray [I]=Prefixtext+I. tostring ();
}
Return Strarray;
}
}
pay attention to the following points:
1. because the Web Service provides services for the Ajax framework, you must add the attribute declaration before the class declaration:
[system. web. script. services. scriptservice]
2. note the gettextstring method. All methods to provide services for the autocompleteextender control must meet the following three conditions:
. the return type of the method must be string [];
B. the input parameter type of the method must be string, int;
C. the two input parameter names must be prefixtext and count.