面板默认有两个按钮 [英] panel having two buttons as default

查看:91
本文介绍了面板默认有两个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET面板,其中,我放置了两个按钮提交取消。我将提交配置为默认按钮,效果很好。但当我点击取消按钮上的输入键时,它也会提交我的页面。



请帮我克服这个....

I a have a ASP.NET panel, In which, I placed two buttons Submit and Cancel. I configured Submit as Default button, which works well. But when I hit enter key on Cancel button it also submit my page.

Please help me overcome this....

推荐答案

使用 Panel.DefaultButton属性 [ ^ ]。


你是说当取消按钮有焦点时你按Enter键点击取消按钮?如果是这样的话,除非你想使用JavaScript跟踪每个按键操作并不是一个好主意,否则你无能为力。
Are you saying that when the Cancel button has focus and you hit Enter it clicks the Cancel button? If so, there is nothing you can do about that unless you perhaps want to use JavaScript to track every key press which is not a good idea.


你可以使用
Panel.Defaultbutton

设置为提交按钮为 Tadit 的建议。

你应该考虑的另一件事是Defaultbutton的设置并不能保证只有当用户点击Enter Key时才会触发Submit按钮,因为当焦点在其他按钮上时按Enter键将是触发该按钮而不是默认按钮。



因此,请尝试为取消添加

set to the Submit button as Tadit's suggestion.
One more thing you should consider is the setting of Defaultbutton doesn't guarantee only the Submit button is fired when user clicks Enter Key since the behavior is such that when the focus is on other buttons pressing Enter will fire that button instead of default one.

So try to also add a

UseSubmitBehavior="false"

按钮以避免此类行为。


这篇关于面板默认有两个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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