使用AutoComplete Extender实现自动完成功能
来源:互联网 发布:windows malicious 编辑:程序博客网 时间:2024/04/30 18:15
<atlas:AutoCompleteExtender runat="server" ID="autoComplete1">
<atlas:AutoCompleteProperties TargetControlID="TextBox1"
Enabled="True" ServicePath="AutoCompleteService.asmx"
ServiceMethod="GetWordList"
minimumprefixlength="1" />
</atlas:AutoCompleteExtender>
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>
- 使用AutoComplete Extender实现自动完成功能
- Atlas学习手记(4):使用AutoComplete Extender实现自动完成功能
- extaspnet 实现自动完成autocomplete 下拉功能
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能
- jquery.autocomplete 自动完成功能
- jquery autocomplete自动完成功能
- AutoComplete+数据库,自动完成功能
- AjaxPro版自动完成(Autocomplete)功能实现
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery Autocomplete实现文本框自动完成搜索功能
- AjaxPro版自动完成(Autocomplete)功能实现
- jQuery.Autocomplete实现自动完成功能(详解)
- jQuery.Autocomplete实现自动完成功能(详解)
- 可以收缩的目录树
- Web 前端优化最佳实践之 CSS 篇
- 什么是ArrayList?
- 制作视频教程的屏幕录像软件大搜集
- Ajax的AutoCompleteExtender的使用
- 使用AutoComplete Extender实现自动完成功能
- Java "数据集"
- javascript表格列排序
- C#中对字符串的操作
- ASP.NET AJAX Control Toolkit 实现按拼音模糊检索下拉框
- MySQL数据库运用技巧和优化
- 一些SQL语句
- 读取注册表(delphi)
- UNIX/LINUX 平台可执行文件格式分析--转载