如何阻止Enter按钮提交? [英] How to stop the Enter Button from Submitting?

查看:78
本文介绍了如何阻止Enter按钮提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页表单,我希望任何键盘上的Enter按钮都不提交表单。有没有一种干净的方法在c#或ASP.NET中执行此操作?

I have a web form that I would like for the Enter Button on any keyboard not to submit the form. Is there a clean way of doing this in c# or in ASP.NET?

推荐答案

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols。 button.usesubmitbehavior(v = vs.110).aspx [ ^ ]



设置UseSubmitBehavior =Falseon你的按钮。这将禁用Enter上的AutoPostback。
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.usesubmitbehavior(v=vs.110).aspx[^]

Set UseSubmitBehavior="False" on your Buttons. This disables the "AutoPostback" on Enter.


检查 http://www.aspsnippets.com/Articles/Disable-Enter-key-in-TextBox-to-avoid-postback-in-ASP.Net.aspx [ ^ ]


这篇关于如何阻止Enter按钮提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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