在textbox asp.net C#中键入时显示DropDown列表中的结果 [英] Showing Results in DropDown list while typing in textbox asp.net C#

查看:93
本文介绍了在textbox asp.net C#中键入时显示DropDown列表中的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Assalam-o-Alaikum,



我想像facebook一样制作文本框(搜索框),即当我打字时,它会根据文字频繁显示和更改结果正在写是否可以在asp.net c#?

解决方案

jQuery UI自动完成

这称为自动完整的文本框。有一个jQuery UI小部件可用于此: http://jqueryui.com/autocomplete/



特别是,单击Remote with cache示例(从上页右侧的示例列表中),了解如何使用回调。您可以单击查看源以查看他们如何创建示例。请注意,您不必进行缓存。



该回调将调用您构建的C#Web服务。要从JavasScript调用Web服务,请参阅: http:// msdn。 microsoft.com/en-us/library/bb398998(v=vs.90).aspx



您可以从创建简单的Web服务开始只返回一个字符串列表(比如,你最喜欢的3个动物,或者你想要的任何东西)。然后,一旦你有了这个工作,你可以修改你的web服务来查看被搜索的术语,然后执行一些查询(例如,对数据库)以返回有效的结果。



Pure ASP.NET Alternative

如果您不想使用jQuery,可以使用: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx

Assalam-o-Alaikum,

I want to make textbox(searchbox) like facebook i.e when I am typing it is showing and changing result frequently depending upon text being written. Is it possible in asp.net c#?

解决方案

jQuery UI Autocomplete
This is called an auto-complete textbox. There is a jQuery UI widget available for this: http://jqueryui.com/autocomplete/.

In particular, click the "Remote with cache" example (from the examples list on the right of the above page) to see how to use a callback. You can click "view source" to see how they created their example. Note that you don't have to do the caching.

That callback will call a C# web service that you build. To call a web service from JavasScript, see this: http://msdn.microsoft.com/en-us/library/bb398998(v=vs.90).aspx.

You can start by creating a simple web service that just returns a list of strings (say, your 3 favorite animals, or whatever you want). Then, once you have that working, you can modify your web service to look at the term being searched for, then perform some query (e.g., against a database) to return valid results.

Pure ASP.NET Alternative
If you don't want to use jQuery, you can use this: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx.


这篇关于在textbox asp.net C#中键入时显示DropDown列表中的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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