ASP.NET webforms 中的 jQuery 自动完成? [英] jQuery autocomplete in ASP.NET webforms?

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

问题描述

有没有人使用 jQuery 在使用 ASP.NET webforms 的文本框上填充自动完成列表?如果是这样,任何人都可以推荐一个好的方法吗?从我到目前为止的阅读来看,似乎大多数人都在使用分隔列表而不是 JSON 来恢复项目.我愿意接受任何能让我快速上手的想法.

解决方案

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

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

文档在示例中显示了 php,但插件本身的工作方式没有区别,因此我不必做任何特别的事情.

来自文档:

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

<块引用>

在上面的例子中,自动完成需要一个带有 id 的输入元素输入框"存在.当一个用户开始在输入框中输入,自动完成程序将请求带有 GET 的 my_autocomplete_backend.php名为 q 的参数包含输入框的当前值.让我们假设用户已经输入foo"(不带引号).自动完成然后会要求my_autocomplete_backend.php?q=foo.

后端应该可以输出自动完成程序的值,每个单行.输出不能包含管道符号|",因为那是被认为是一个分隔符(更多关于那个稍后).

一个合适的简单输出是:富傻子脚松垮垮的富战士食物大战

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

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

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