Experience the new Ajax toolkit control: autocompleteextender

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.