ASP.Net页面回车键后造成回 [英] ASP.Net page enter key causing post back
问题描述
我有postsback当它应该不是一个aspx页面。有两个文本框,两个ListBox在页面上两个按钮。如果在任何点回车键为pressed第一个按钮提供焦点,并点击导致列表框选择范围内的损失。
I have an aspx page that postsback when it should not. there are two text boxes, two listboxes and two buttons on the page. if at any-point the enter key is pressed the first button is given focus and "clicked" resulting in a loss of selection within the listboxes.
我如何禁用此?对于如何捕捉输入按钮,执行一个方法,但我可以找到一个关于如何简单地禁用整齐吨教程让我抢的第一个按钮我找到并点击功能上面提到的。
How do I disable this? there are tons of tutorials on how to capture the enter button and execute a method but I could find one on how to simply disable the neat "let me grab the first button I find and click it" feature mentioned above.
推荐答案
- 您可以设置<一个href=\"http://www.google.de/url?sa=t&source=web&cd=2&ved=0CCQQFjAB&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fsystem.web.ui.webcontrols.panel.defaultbutton.aspx&rct=j&q=defaultbutton%20asp.net%20msdn%20enter&ei=uV3kTN_FFoPusgat0ZCfBA&usg=AFQjCNFs-cyTNnL6uYI95Xu3uKSA867LUQ&sig2=rloNUXwjuBKnxGirNNTR3w&cad=rja\">DefaultButton在窗体或面板。这样,您有完全控制权发生了什么。
- 设置<一个href=\"http://www.google.de/url?sa=t&source=web&cd=2&ved=0CCIQFjAB&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fsystem.web.ui.webcontrols.button.usesubmitbehavior.aspx&rct=j&q=asp.net%20UseSubmitBehavior&ei=jF3kTN7DKY_6sgaH44DsCw&usg=AFQjCNHxfCWvxIlAAzNMpnIJzZKF-it9RA&sig2=HZZ5bldRmjXhGxt4D3iVnw&cad=rja\">UseSubmitBehavior=\"False\"在你的按钮。这将禁用进入自动回。
- You could set the DefaultButton on the Form or a Panel. This way you have full control what happens.
- Set UseSubmitBehavior="False" on your Buttons. This disables the "AutoPostback" on Enter.
如果我想prevent回发上完全进入我preFER第二。
I would prefer the second if i wanted to prevent Postbacks on Enter completely.
这篇关于ASP.Net页面回车键后造成回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!