zoukankan      html  css  js  c++  java
  • 搜索功能 自动完成输入提示

    搜索功能
    自动完成输入提示:
    VS2010工具栏添加新项AjaxControlToolkit.dll

    前台:
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            搜索 :
            <asp:TextBox ID="txtSearch" runat="server" Height="25px" Width="359px"></asp:TextBox>
            <asp:AutoCompleteExtender
            ID="AutoCompleteExtender1"
            runat="server"
            TargetControlID="txtSearch"
            ServicePath="AutoComplete.asmx"
            ServiceMethod="GetCompletionList"
            MinimumPrefixLength="2"
            CompletionSetCount="10"
            ></asp:AutoCompleteExtender>

            <!--MinimumPrefixLength:出现提示时的文字最小长度,CompletionSetCount:文本提示的个数-->


    WebServices 服务:
    ==================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;

    /// <summary>
    ///AutoComplete 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService {

        public AutoComplete () {

            //如果使用设计的组件,请取消注释以下行
            //InitializeComponent();
        }

        [WebMethod]
        public string HelloWorld() {
            return "Hello World";
        }


        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            List<string> strList = new List<string>();
            count = count == 0 ? 10 : count;
            Random r = new Random();
           
            for (int i = 0; i < count; i++)
            {
              string newStr= ((char)(r.Next(65, 90))+(char)(r.Next(97, 122))+(char)(r.Next(97,122))).ToString();
              strList.Add(prefixText + newStr);
            }
            return strList.ToArray();
        }

    }

  • 相关阅读:
    NET領域模型(1)
    oracle 函數索引(1)
    oracle 動態SQL(1)
    WF事件驱动(5)
    WF事件驱动(3)
    WF事件驱动(4)
    HP LoadRunner 11.00 新鲜尝
    Tomcat配置优化要点
    WebSphere性能诊断与调优
    性能测试工具、监控工具
  • 原文地址:https://www.cnblogs.com/lt-style/p/3449120.html
Copyright © 2011-2022 走看看