简体   繁体   English

禁用Internet Explorer的默认行为

[英]disable default behaviour of Internet Explorer

I am using asp.net C#. 我正在使用asp.net C#。

I have one html input field, and 3 image buttons (asp.net controls) 我有一个html输入字段和3个图像按钮(asp.net控件)

  • ImageButton 1 = perform delete operation ImageButton 1 =执行删除操作

  • ImageButton 2 = perform Edit operation ImageButton 2 =执行编辑操作

  • ImageButoon 3 = perform duplicate operation ImageButoon 3 =执行重复操作

My problem occurs when the user presses the enter key when the input field is in focus. 当用户在输入字段处于焦点状态时按Enter键时,会发生我的问题。 When he presses the enter key the browser automatically fires by default the next button. 当他按下Enter键时,浏览器默认会自动触发下一个按钮。 In my case it is the delete operation. 就我而言,这是删除操作。

How can I prevent this? 我该如何预防?

正确配置DefaultButton属性。

you can also hide a button at the top of your page/form that will attract the attention of IE when you hit enter. 您还可以在页面/表单顶部隐藏一个按钮,当您按Enter键时,该按钮将引起IE的注意。

<button style='position:absolute;left:-1000px'>IE sux</button>

that button won't display on the screen but IE will click it whenever you hit enter. 该按钮将不会显示在屏幕上,但是只要您按Enter键,IE就会单击它。 since it has no action on click, nothing will happen. 由于它对点击没有任何作用,因此什么也不会发生。

note: only works in IE9. 注意:仅适用于IE9。 perhaps useful with the default button option above. 可能对上面的默认按钮选项有用。

As mentioned above, use the form's defaultbutton property or it you use a panel use that of the panel. 如上所述,使用表单的defaultbutton属性,或者使用面板使用面板的defaultbutton属性。

http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton(VS.80).aspx http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton(VS.80).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM