Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

Recently I have added DefaultButton attribute to Panel control.

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


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!
Posted

 
Share this answer
 
Comments
MK-Gii 27-May-14 6:31am    
Hey. Thanks for posting it back. Tried various things - it seems to be working with most of the controls but not with the DropDownList... odd. Looks like even javascript is being interpreted diferently by the FireFox as I've used js to handle the event - worked on all browsers except FireFox v29.0.1. I guess I still need to look for a fix/solution.
Solution for this - add JavaScript to handle this.
This is attached to "MyDropDown" control.

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900