DefaultButton不适用于FireFox [英] DefaultButton does not work with FireFox

查看:104
本文介绍了DefaultButton不适用于FireFox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

最近,我已将DefaultButton属性添加到面板控件.

Hello Guys,

Recently I have added DefaultButton attribute to Panel control.

<asp:Panel runat="server" DefaultButton="Submit">
<asp:dropdownlist id="Food_Selector" runat="server"></asp:dropdownlist>
</asp:Panel>



现在-当我定位/聚焦此下拉元素(使用鼠标或使用TABing在其上移动)并按Enter时-它的作用应与ID为提交"的按钮相同.它在IE,谷歌浏览器上都可以正常运行,但不适用于FireFox.对于FireFox,我必须另外按住"ALT"才能使其正常工作.

任何人都有头绪,这里最好的解决方案是什么?

附言:避免使用JavaScript会很好.



Now - when I target/focus this dropdown element (with mouse or moving on it with TABing) and press Enter - it should act the same as pressing button whose ID is "Submit". It works fine on IE, Google Chrome, but does not work with FireFox. With FireFox I have to additionaly hold "ALT" in order for this to work.

Anyone have a clue, what could be the most optimal solution here?

P.S.: would be nice to avoid JavaScript.

Thanks!

推荐答案

以下链接可能会帮助您:

http://forums.asp.net/t/1645254.aspx?Panel + default + button + property + is + not + working + in + Firefox [
The following link might help you:

http://forums.asp.net/t/1645254.aspx?Panel+default+button+property+is+not+working+in+Firefox[^]


解决方案-添加JavaScript来处理此问题.
这附加到"MyDropDown"控件.

Solution for this - add JavaScript to handle this.
This is attached to "MyDropDown" control.

document.getElementById("MyDropDown").onkeydown = function (e) {
    if (e.keyCode == 13)
    {
        document.getElementById("<%=SigninBtn.ClientID %>").click();
    }
}


这篇关于DefaultButton不适用于FireFox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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