您的位置:首页 > 编程语言 > C#

autoComplete +C#的应用 实例总结

2008-06-25 10:05 381 查看
我只是对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:

onkeyup="autoComplete.hdleEvent(event)" 

      ondblclick="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'
},

效果图片:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: