Google auto-sensing cable acquisition function

Source: Internet
Author: User

1. Web Page

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "autocomplete. aspx. cs" inherits = "ch09_autocomplete" %>

<% @ Register Assembly = "ajaxcontroltoolkit" namespace = "ajaxcontroltoolkit" tagprefix = "PC3" %>

<% @ Register Assembly = "system. web. extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "namespace =" system. web. ui "tagprefix =" asp "%>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "head1" runat = "server">
<Title> AutoComplete control example </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div style = "display: inline; font-weight: bold; font-size: 30px; font-family: Arial, verdana">
AutoComplete control example </div>
& Lt; HR width = "100%" size = "1" & gt;

<Asp: scriptmanager id = "scriptmanager1" runat = "server">
</ASP: scriptmanager>

<Asp: Panel id = "Panel1" runat = "server" Height = "50px" width = "400px" borderwidth = "1" backcolor = "white">
<Table align = "center" border = "0" cellpadding = "0" cellspacing = "0" width = "400">
<Tr>
<TD colspan = "2" align = "center">
<Font face = "verdana, "size = "2"> <B> ■ enter basic information ■ </B> </font>
</TD>
</Tr>
<Tr>
<TD bgcolor = "# a3d3ad" Height = "30" width = "70">
<Div align = "right">
<Font color = "#990000" face = "verdana, "size = "2"> <B> address: </B> </font> </div>
</TD>
<TD bgcolor = "# f9f8ee" Height = "30">
<Font face = "" size = "2">
<Asp: textbox id = "txtaddress" runat = "server" columns = "45"> </ASP: textbox>
</Font>
</TD>
</Tr>
</Table>
</ASP: Panel>
<C0: autocompleteextender id = "autocompleteextender1" runat = "server"
Targetcontrolid = "txtaddress" servicemethod = "getcompletionlist"
Servicepath = "autocomplete. asmx" minimumprefixlength = "1"
Completioninterval = "500">
</PC3: autocompleteextender>

</Form>
</Body>

</Html>

 

2. WebService

<% @ WebService Language = "C #" class = "AutoComplete" %>

Using system;
Using system. Web;
Using system. collections;
Using system. Web. Services;
Using system. Web. Services. Protocols;
Using system. Collections. Generic;
Using system. Data;
Using system. Web. UI;
Using system. Web. UI. webcontrols;

[WebService (namespace = "http://tempuri.org/")]
[Webservicebinding (conformsto = wsiprofiles. basicprofile1_1)]
[System. Web. Script. Services. scriptservice]
Public class AutoComplete: system. Web. Services. WebService
{
[Webmethod]

Public String [] getcompletionlist (string prefixtext, int count)
{

If (COUNT = 0)
{
Count = 10;
}

// Specific query operations
// List <string> items = new list <string> (count );

// Car2100.model. Enterprise. user_info model = new car2100.model. Enterprise. user_info ();

// Car2100.bll. Enterprise. user_info BLL = new car2100.bll. Enterprise. user_info ();

// Return BLL. GetUserName (prefixtext, count );

}

}

3. attributes of the autocompleteextender Control

Client AutoComplete BehaviorInherited fromSYS. UI. Behavior(For details about SYS. UI. behavior, see create a custom behavior in ASP. NET Atlas ). AutoComplete behavior has the following attributes:

  1. Serviceurl: The path of the server-side Web service that provides the Automatic completion function.
  2. Servicemethod: The name of the web method on the server that provides the Automatic completion function. The web method should have a similar signature:Public String [] getsuggestions (string prefixtext, int count). WherePrefixtextThe string that is currently input by the client,CountReturns the maximum number of entries in the returned prompt list.StringArray, indicating the prompt list.
  3. Minimumprefixlength: Start to provide the minimum number of input characters in the automatically completed list text box. The default value is 3. If you have just entered one or two letters, you can't wait to provide them with a long list. This makes no sense and wastes a lot of server and network resources. The suggestions provided are valuable only when the user inputs a value equal to or greater than a certain number (set by this attribute, the corresponding method on the server is queried and displayed to the user prompt list.
  4. Completioninterval: The interval between the query backend and the default value is 1000 (MS ). If the value is too large, it will give the user the impression of slow program response. If the value is too small, it will increase the burden on the server and the network. Generally,-is a reasonable value.
  5. Completionlist: Displays the DOM elements in the prompt list. If this parameter is not specified, Atlas automatically creates a div under the related textbox for display. In general, we do not need to specify this attribute.
  6. Completionsetcount: Maximum number of items in the prompt list. The default value is 10.

ServerAutoComplete ExtenderIt inherits from extendercontrol. Similarly, it has the following attributes:

  1. Servicepath: Similar to the client AutoComplete BehaviorServiceurlAttribute.
  2. Servicemethod: Similar to the client AutoComplete BehaviorServicemethodAttribute.
  3. Dropdownpanelid: Similar to the client AutoComplete BehaviorCompletionlistAttribute, but the ID of the server <asp: Panel/> is specified here. In general, we do not need to specify this attribute.
  4. Minimumprefixlength: Similar to the client AutoComplete BehaviorMinimumprefixlengthAttribute.

When using the server-side AutoComplete extender, you must specify at least oneAutocompletepropertiesChild widget. The autocompleteproperties control is used to specify the auto-completion function for a specific textbox. It also provides some attributes, includingServicepath,ServicemethodAndMinimumprefixlengthThree attributes. If you set an attribute in both AutoComplete extender and autocompleteproperties, the setting in autocompleteproperties overwrites the setting in AutoComplete extender. In addition, autocompleteproperties also provides the following attributes:

  1. Enabled: Whether to enable auto-completion. You should set it to true to enable auto-completion. The default value is false.
  2. Targetcontrolid: Specify the textbox to which the auto-completion function will be applied, and set it to the ID of the textbox on the server side.

 

 

 

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.