ASP.NET AJAX Toolkit Combobox:无需单击 ENTER 两次即可回发
我在我的应用程序中使用 ComboBox 来实现功能,并且我有 AutoCompleteMode="Suggest"。
但是,在我在文本框中输入搜索后,我需要按 ENTER 两次才能回发并显示一些结果。这是默认行为,如官方演示。 在我看来,这有点烦人而且不直观......
有人知道如何避免这种行为,并只按一次吗?
提前致谢
im using a ComboBox for a feature in my application, and i have AutoCompleteMode="Suggest".
However, after i type in the textbox for a search, i need to press ENTER twice to postback and show some results. This is the default behavior, like its shown in the oficial demonstration.
In my opinion, its kinda annoying and not intuitive...
Anyone have a clue how to avoid this behavior, and press just one time?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题并解决了它:
如果您不希望按钮被单击两次,则必须将 autopostback 属性设置为“false”。
I faced the same problem and solved it:
You must set autopostback property to "false" if you dont want button to be clicked twice.
将控件的
AutoPostback
属性更改为true
。这将捕获 Tab 键,该键会起作用,因为控件失去焦点。我怀疑是否有一个好方法来捕获回车键,除非您准备打开源代码并执行一些修改。
Change the
AutoPostback
attribute of the control totrue
. This will trap the tab key, which works because the control loses focus.I doubt there is a good way to trap the enter key for this, unless you're up for breaking open the source code and performing some modifications.
汤姆,简是对的,我以前也遇到过这种事。你只需要将 autopostback 设置为 false 即可。因此,您可能需要将 ComboBox autopostback 设置为 false。
Tom, Jan is right and it happened to me before. you just need to set you autopostback to false. So, probably you need to set the ComboBox autopostback to false.
我设法用下面的代码解决了这个问题:
在您的 aspx 文件中,组合框控件将是:
然后,添加对 javascript 文件的引用,并在其中添加以下函数:
我希望上面的代码能够回答您的问题。
I managed to solve this problem with the code below:
In your aspx file, the combobox control will be:
Then, add a reference to a javascript file, and add there the following function:
I hope my code above answers your question.