<atlas:AutoCompleteExtender runat="server"
ID="autoComplete1">
<atlas:AutoCompleteProperties TargetControlID="TextBox1"
Enabled="True" ServicePath="AutoCompleteService.asmx"
ServiceMethod="GetWordList"
minimumprefixlength="1" />
</atlas:AutoCompleteExtender>
|
属性
|
描述
|
|
ServicePath
|
指定自动完成功能Web Service的路径
ServicePath
="AutoCompleteService.asmx"
|
|
ServiceMethod
|
指定自动完成功能Web Method的名称
ServiceMethod
="GetWordList"
|
|
DropDownPanelID
|
指定显示列表的Panel的ID,一般情况会提供一个默认的,我们无需指定
|
|
minimumprefixlength
|
开始提供自动完成列表的文本框内最少的输入字符数量。
minimumprefixlength
="1"
|
|
属性
|
描述
|
|
ServicePath
|
同AutoComplete Extender的ServicePath
|
|
ServiceMethod
|
同AutoComplete Extender的ServiceMethod
|
|
minimumprefixlength
|
同AutoComplete Extender的minimumprefixlength
|
|
Enabled
|
是否开启自动完成功能,默认值为false
Enabled
="True"
|
|
TargetControlID
|
指定自动完成功能应用到哪个TextBox上,设置Web服务器TextBox控件的ID
TargetControlID
="TextBox1"
|
access control list (ACL)
ADO.NET
aggregate event
alpha channel
anchoring
antialiasing
application base
application domain (AppDomain)
application manifest
application state
ASP.NET
ASP.NET application services database
ASP.NET mobile controls
ASP.NET mobile Web Forms
ASP.NET page
ASP.NET server control
ASP.NET Web application
assembly
assembly cache
assembly manifest
assembly metadata
assertion (Assert)
association class
ASSOCIATORS OF
asynchronous method
attribute
authentication
authorization
autopostback
bounds
boxing
C#
card
catalog
CCW
chevron
chrome
cHTML
CIM
CIM Object Manager
CIM schema
class
client area
client coordinates
clip
closed generic type
CLR
CLS
CLS-compliant
code access security
code-behind class
code-behind file
code-behind page
COM callable wrapper (CCW)
COM interop
Common Information Model (CIM)
common language runtime
common language runtime host
Common Language Specification (CLS)
common object file format (COFF)
common type system (CTS)
comparison evaluator
composite control
configuration file
connection
connection point
constraint
constructed generic type
constructed type
consumer
container
container control
content page
context
context property
contract
control state
cross-page posting
CTS
custom attribute (Attribute)
custom control
using System;
using System.IO;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
/**//// <summary>
/// Summary description for AutoCompleteService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AutoCompleteService : System.Web.Services.WebService
{
public AutoCompleteService ()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
private static string[] autoCompleteWordList = null;
[WebMethod]
public String[] GetWordList(string prefixText, int count)
{
if (autoCompleteWordList == null)
{
string[] temp = File.ReadAllLines(Server.MapPath("~/App_Data/words.txt"));
Array.Sort(temp, new CaseInsensitiveComparer());
autoCompleteWordList = temp;
}
int index = Array.BinarySearch(autoCompleteWordList, prefixText,
new CaseInsensitiveComparer());
if (index < 0)
{
index = ~index;
}
int matchingCount;
for (matchingCount = 0;
matchingCount < count && index + matchingCount < autoCompleteWordList.Length; matchingCount++)
{
if (!autoCompleteWordList[index + matchingCount].StartsWith(prefixText,
StringComparison.CurrentCultureIgnoreCase))
{
break;
} }
String[] returnValue = new string[matchingCount];
if (matchingCount > 0)
{
Array.Copy(autoCompleteWordList, index, returnValue, 0,
matchingCount); } return returnValue; }
}
<atlas:ScriptManager id="AtlasPage1" runat="server" />
<div class="page"id="links">

<div id="content">
<h2>AutoComplete server control</h2>
<asp:TextBox ID="TextBox1" runat="server" Width="220px"></asp:TextBox>
<atlas:AutoCompleteExtender runat="server"
ID="autoComplete1">
<atlas:AutoCompleteProperties
TargetControlID="TextBox1"
Enabled="True" ServicePath="AutoCompleteService.asmx"
ServiceMethod="GetWordList"
minimumprefixlength="1" />
</atlas:AutoCompleteExtender>
</div>
</div>
本文介绍如何使用Atlas中的AutoCompleteExtender实现自动完成功能。通过示例展示了配置AutoCompleteExtender及其属性的方法,包括指定目标TextBox、WebService路径及方法等。
133

被折叠的 条评论
为什么被折叠?



