autoComplete +C#的应用 实例总结

我只是对autoComplete使用的总结,以备自己以后再次用到。具体autoComplete.js是谁写的谁创的,我就不清楚了 。不过真心地感谢这些认真写代码的人。

先看看用到文件

四步走:

1:

//加入样式码

<style type="text/css" media="all" title="Default">

      @import "../css/automain.css";

      @import "../css/Searchautocomplete.css";

</style>



2:



   public string _autocommpeletLs = "";



    //处理搜索自动填充

    protected void SetcommpleteList()

   {

       this._autocommpeletLs = Uz_Server.GetAutocompeletTextList("building","buildingname","where isbuilding=1");

   }





3:

//加入js代码

<%--处理搜索的js代码--%>

    <script type="text/javascript" src="../js/neverModules-autoComplete.js"></script>

    <script type="text/javascript">

    //<![CDATA[

      completeDataSource = [

<%=this._autocommpeletLs %>

      ];

      

      var autoComplete = null;

      onload = function pageLoadHdle() {

        var configuration = {

          instanceName: "autoComplete",

          textbox: document.getElementById("ctl00$ContentPlaceHolder1$Uz_SearchBar1$keywordtxt"),

          dataSource: completeDataSource

        };



        autoComplete = new neverModules.modules.autocomplete(configuration);

        

        

        autoComplete.useContent = true;

				autoComplete.useSpaceMatch = true;

				autoComplete.ignoreWhere = true;

        autoComplete.create();

        autoComplete.expandAllItem();



        autoComplete.showAnimateImage("img/indicator.gif");



        window.setTimeout(

          function closeAnimateImageAfter1seconds() { 

            autoComplete.closeAnimateImage();

          }, 1000);

      }

    //]]>

    </script>





4:

οnkeyup="autoComplete.hdleEvent(event)" 

      οndblclick="autoComplete.expandAllItem();"





.onfocus

 

讨论第二步,

这是一个C#的方法,目的是从数据库取出数据通过一个属性付给给js代码。

返回的数据格式是:

        {           'text':'blueDestiny',           'content':'BlueDestiny[a]126.com'         },         {           'text':'never-online',           'content':'BlueDestiny[a]126.com',           'hints':'http://www.never-online.net'         },

效果图片:

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

系统商研社

一切付出都是明智的

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值