New Extension Feature of ASP. NET Ajax Control Toolkit: autocompleteextender

Source: Internet
Author: User

We have always hoped that Atlas will provide AutoComplete extension features, and we will be able to live up to expectations. This feature is already included in the latest ASP. NET Ajax Control Toolkit: autocompleteextender. It is easy to use.
The following is a stock.CodeFor example, enter a part of the Code, an abbreviation of Pinyin, or a Chinese character to get all the prompts.

1. Add a textbox.
<Asp: textbox runat = "server" id = "txtstockkeyname" width = "300" AutoComplete = "off"/>

2. Add autocompleteextender and set parameters.
<PC3: autocompleteextender
Runat = "server"
Id = "autocomplete1"
Targetcontrolid = "txtstockkeyname"
Servicepath = "stockcode. asmx"
Servicemethod = "getstocklist"
Minimumprefixlength = "1"
Completioninterval = "1000"
Enablecaching = "true"
Completionsetcount = "12"
/>

Parameter description:
Targetcontrolid: Enter the text box for the query keyword
Servicepath: the address of the backend WebService
Servicemethod: Method Name of the WebService corresponding to the background
Minimumprefixlength: the minimum length automatically completed when a keyword is queried.
Completioninterval: Query Result Display interval (MS)
Enablecaching: Enable Cache
Completionsetcount: displays the number of query results

3. WebService Method for returning query results based on query keywords
 

Using System;
Using System. Web;
Using System. collections;
Using System. Web. Services;
Using System. Web. Services. Protocols;
Using System. Collections. Generic;
Using System. collections;

/**/ /// <Summary>
///Stockcode Summary
/// </Summary>
[WebService (namespace =   " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
[System. Web. Script. Services. scriptservice]
Public   Class Stockcode: system. Web. Services. WebService {

Public Stockcode () {

//If you use the designed components, uncomment the following lines:
//Initializecomponent ();
}

[Webmethod]
Public   String [] Getstocklist ( String Prefixtext, Int Count)
{
If (Count =   0 )
{
Count= 10;
}

Random random =   New Random ();
List < String > Items =   New List < String > (Count );

For ( Int I =   0 ; I < Stockid. length; I ++ )
{
If (
(Stockid [I]. indexof (prefixtext) > =   0 )
| (Stockname [I]. indexof (prefixtext) > =   0 )
| (Stockpy [I]. toupper (). indexof (prefixtext. toupper ()) > =   0 )
)
{
Items. Add (stockid [I]+ ":" +Stockname [I]);
}
}

Return Items. toarray ();
}

// Stock Code
String [] Stockid =   {"610001","610002","611003","611004"} ;
// Abbreviation of stock pinyin
String [] Stockpy =   {"XG","NG","XJ","XC"} ;
// Stock name
String [] Stockname =   {"Watermelon","Pumpkin","Bananas","Sausage"} ;

}

:


Sample Code:
/Files/heekui/stockid.rar

Running environment:
Vs2005 and ASP. NET Ajax v 1.0 + ASP. NET Ajax Control Toolkit

 

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.