zoukankan      html  css  js  c++  java
  • AutoCompleteExtender

    这是一个webservices,在aspx中调用就行了!
    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)]
    [System.Web.Script.Services.ScriptService]
    public class AutoCompleteService : System.Web.Services.WebService
    {
    public AutoCompleteService()
    {
    //Uncomment the following line if using designed components
    //InitializeComponent();
    }

    private static string[] autoCompleteWordList = null;

    [WebMethod]
    //******光之翼 QQ272912705     www.hi.baidu.com/jcomet*******
    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;
    }
    }
  • 相关阅读:
    Java动态代理
    图解Python 【第七篇】:网络编程Socket
    我的FP感悟
    Scala微服务架构 三
    Scala微服务架构 二
    Scala微服务架构 一
    一篇入门 -- Scala
    基于DobboX的SOA服务集群搭建
    hadoop 异常及处理总结-01(小马哥-原创)
    使用Eclipse的几个必须掌握的快捷方式(能力工场小马哥收集)
  • 原文地址:https://www.cnblogs.com/jcomet/p/1242807.html
Copyright © 2011-2022 走看看