jQuery的自动完成在ASP.NET web表单? [英] jQuery autocomplete in ASP.NET webforms?

查看:111
本文介绍了jQuery的自动完成在ASP.NET web表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人使用jQuery来填充使用ASP.NET web表单文本框的自动完成列表?如果是这样,任何人都可以推荐一个好方法是什么?从我的阅读,到目前为止,似乎大多数人都使用分隔的列表,而不是JSON带来的项背。我接受任何想法,将让我和相当快速运行。


解决方案

有在网络上很多很多的例子。我以前用过这个,如果我还记得你只需要创建一个aspx,将返回匹配的术语为< BR /> 分隔列表:

http://www.dyve.net/jquery/?autocomplete

文档显示PHP中的例子,但有一个在路上没有区别本身的工作插件,我没有做什么特别的结果。

从文档:

 > $(#INPUT_BOX)自动完成(my_autocomplete_backend.php);


  

在上面的例子中,自动填充
  期待与ID输入元素
  INPUT_BOX存在。当用户
  开始在输入框中输入时,
  autocompleter会要求
  用GET my_autocomplete_backend.php
  参数为q包含
  输入框的当前值。让我们
  假定用户已键入
  富(不带引号)。自动完成
  然后将请求
  my_autocomplete_backend.php Q = foo的。


  
  

后端应该输出可能
  对于autocompleter值,每个上
  单行。输出不能包含
  管道符号|,因为这是
  考虑分隔符(更多的
  更高版本)。


  
  

一个适当的简单的输出将是:
  富
  傻子
  脚丫子
  自由自在
  Foo Fighters乐队
  食物大战


Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET webforms? If so, can anyone recommend a good method? From my reading so far, it seems like most people are using delimited lists rather than JSON to bring the items back. I'm open to any ideas that will get me up and running rather quickly.

解决方案

There are many, many examples on the web. I've used this one before, and if I recall you only need to create an aspx that will return matching terms as a <BR/> separated list:

http://www.dyve.net/jquery/?autocomplete

The documentation shows php in the example, but there's no difference in the way the plugin itself works and I didn't have to do anything special as a result.

From the documentation:

> $("#input_box").autocomplete("my_autocomplete_backend.php");

In the above example, Autocomplete expects an input element with the id "input_box" to exist. When a user starts typing in the input box, the autocompleter will request my_autocomplete_backend.php with a GET parameter named q that contains the current value of the input box. Let's assume that the user has typed "foo"(without quotes). Autocomplete will then request my_autocomplete_backend.php?q=foo.

The backend should output possible values for the autocompleter, each on a single line. Output cannot contain the pipe symbol "|", since that is considered a separator (more on that later).

An appropiate simple output would be: foo fool foot footloose foo fighters food fight

这篇关于jQuery的自动完成在ASP.NET web表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆