aspx页面

需要引用的文件:

<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.autocomplete.js"></script>

script:

<script type="text/javascript" language="javascript">

$().ready(function() {

$.ajax({         contentType: "application/json",

url: "AutoComplete.ashx",

dataType: "json",

success: function (msg) {

$("#reg_XIAOQU").autocomplete(msg, {

minChars: 1,                    //最少输入字条

max: 40,

autoFill: false,                //是否选多个,用","分开

mustMatch: false,               //是否全匹配, 如数据中没有此数据,将无法输入

matchContains: true,            //是否全文搜索,否则只是前面作为标准

scrollHeight: 220,

width: 200,

multiple: false,

formatItem: function (row, i, max) {                    //显示格式

return "<span>" + row.alladress + "</span>";                     },

formatMatch: function (row, i, max) {               //以什么数据作为搜索关键词,可包括中文,

return row.alladress;                     },

formatResult: function (row) {                      //返回结果

return row.alladress;                     }

}).result(function (event, data, formatted) {

alert(data.alladress);                     //根据最终返回的数据做处理

});         }     });

});

</script>

后台代码处理页AutoComplete.ashx:

using System;

using System.Web;

using System.Data;

using System.Collections.Generic;

using System.Web.Script.Serialization;

public class AutoComplete : IHttpHandler {

public void ProcessRequest (HttpContext context) {

context.Response.ContentType = "text/plain";

ServiceWS myWS = new ServiceWS();     //实例化数据操作类

string sql = "Select alladress From LIVINGAREA";

DataSet ds = myWS.GetDsFromSql(sql);

if (ds.Tables[0]!=null)          {

string data = DbHelper.DataTable2Json(ds.Tables[0]);

context.Response.Write(data);

context.Response.Flush();

context.Response.End();

}

}

public bool IsReusable {

get {             return false;         }

}

}

效果图:

AutoComplete的更多相关文章

  1. autocomplete的使用

    autocomplete使用分为本地调用方法和读取远程读取数据源的方法 (1)本地调用方法 <script src="Scripts/jquery-1.4.1.min.js" ...

  2. 原生js实现autocomplete插件

    在实际的项目中,能用别人写好的插件实现相关功能是最好不过,为了节约时间成本,因为有的项目比较紧急,没充分时间让你自己来写,即便写了,你还要花大量时间调试兼容性.但是出于学习的目的,你可以利用闲暇时间, ...

  3. jQuery ui autocomplete 与easyUI冲突解决办法(重命名ui的autocomplete 和menu部分)

    http://jqueryui.com/download/   UI定制只选autocomplete 会自动把依赖的menu模块也加入进来--然而easyUI也有自己的menu,于是就-- 折腾了好久 ...

  4. Bootstrap 中的 Typeahead 组件 -- AutoComplete

    Bootstrap 中的 Typeahead 组件就是通常所说的自动完成 AutoComplete,功能很强大,但是,使用上并不太方便.这里我们将介绍一下这个组件的使用. 第一,简单使用 首先,最简单 ...

  5. smartComplete——轻量级的autoComplete插件,开源

    项目后端觉得autoComplete响应略慢,于是花了两天时间写了这插件,基于jQuery 1.7+,仓库地址 https://github.com/VaJoy/smartComplete ,欢迎各种 ...

  6. Autocomplete 自动补全(Webform实战篇)

    开篇语 因为项目中需要用到一个自动补全的功能,功能描述: 需求一:新增收件人的时候,自动下拉显示出数据库中所有的收件人信息(显示的信息包括:姓名-收件地址-联系方式) 需求二:选中一个值得时候,分别赋 ...

  7. jQuery AutoComplete在AJAX UpdatePanel环境中PostBack之后无法工作

    前些日子,Insus.NET有实现<ASP.NET MVC使用jQuery实现Autocomplete>http://www.cnblogs.com/insus/p/5638895.htm ...

  8. jQuery AutoComplete 自动补全

    jQuery.AutoComplete是一个基于jQuery的自动补全插件.借助于jQuery优秀的跨浏览器特性,可以兼容Chrome/IE/Firefox/Opera/Safari等多种浏览器. 特 ...

  9. autocomplete="off" 不起作用

    首先来了解一下 表单自动填充的原理,当我们登录的时候,如果选择的记住登录密码,那么后续界面中如果有 <input type="text" name="field1& ...

随机推荐

  1. SQL*Plus环境下创建PLUSTRACE角色

    普通用户在SQL*Plus中开启AUTOTRACE报告时,遇到SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is ...

  2. [转].net core 通过ViewComponent封装控件 左侧菜单

    本文转自:http://www.cnblogs.com/BenDan2002/p/6224816.html 我们在.net core中还使用了ViewComponent方式生成控件.ViewCompo ...

  3. JS--实现简单轮播(一)

    <!DOCTYPE html><html><head> <title></title> <meta charset=utf-8> ...

  4. plain framework 1 网络流 缓存数据详解

    网络流是什么?为什么网络流中需要存在缓存数据?为什么PF中要采用缓存网络数据的机制?带着这几个疑问,让我们好好详细的了解一下在网络数据交互中我们容易忽视以及薄弱的一块.该部分为PF现有的网络流模型,但 ...

  5. python 第一章学习课程

    http://www.runoob.com/python/python-dictionary.html

  6. [LeetCode] Remove Invalid Parentheses 移除非法括号

    Remove the minimum number of invalid parentheses in order to make the input string valid. Return all ...

  7. ElasticSearch第四步-查询详解

    ElasticSearch系列学习 ElasticSearch第一步-环境配置 ElasticSearch第二步-CRUD之Sense ElasticSearch第三步-中文分词 ElasticSea ...

  8. phpmyadmin not found

    在 ubuntu 14.04 中使用: > sudo apt-get install phpmyadmin 安装好 phpmyadmin 之后,打开 http://localhost/phpmy ...

  9. TextView字体阴影效果

    android:shadowDx="1" android:shadowDy="1" android:shadowColor="#8c8c8c" ...

  10. python学习之路 第五天

    1.装饰器: #!/usr/bin/env python3 user_status = False #用户登录了就把这个改成True def login(auth_type): #把要执行的模块从这里 ...