Asp.Net 搜索,发现按键变化
我正在尝试在 Asp.Net 中实现一个搜索栏,其中每次按键都会改变结果。 我希望搜索栏包含与他们迄今为止输入的内容相关的可用结果的下拉列表。
因此,如果您正在搜索州,并且输入了 M,它会列出以 M 开头的所有州,但如果您在其中添加 i...它会将结果截断为仅以 Mi 开头的州。
现在我只有一个文本框,当文本更改时调用一个方法。 问题是只有重新加载页面才能看到结果。 我可以在方法中重新加载页面,但这似乎是错误的。
有没有更简单的方法来做到这一点?
I am trying to implement a search bar in Asp.Net where the results change with every key press. I want the search bar to contain a drop down list of available results pertaining to what they have typed in thus far.
So if you were searching for states, and you typed M, it would list all states starting with M, but if you add an i to that...it would truncate the results to to only those that start with Mi.
Right now I have just a textbox that calls a method when the text changes. The problem is you only see the results if you reload the page. I could reload the page in the method but that seems wrong.
Is there an easier way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试 AjaxControl Toolkit 的 AutoComplete..
http://www.asp.net /AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
Try the AjaxControl Toolkit's AutoComplete..
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
我会使用 jQuery 及其 $.autocomplete 方法,因为它更具可定制性。
更多信息和演示此处。
I would use jQuery along with its $.autocomplete method as it's much more customizable.
More info and demo here.