KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am working on a ASP.NET MVC web site that has multiple submit buttons. i.e. <input type="submit" name="SubmitButton" value="Reset" /> <input type="submit" name="SubmitButton" value="OK" /> <input type="submit" name="SubmitButton" value="Back" /> I need to allow users to quickly submitting the form by pressing the 'Enter' key. HTML standard seems to specify that the first submit button will be assumed if a user press the 'Enter' key. However, I need to make the 2nd button (i.e. the "OK") button the default button and for reasons I don't even want to talk about, changing the button order is not an option. I googled around and I found this post about using Page.Form.DefaultButton in ASP.NET but this doesn't work with ASP.NET MVC. I also tried the following javascript solution, while it works in Chrome but doesn't work in IE6 $('body').keypress(function(e) { if (e.which === 13) { $("input[value='OK']").trigger('click'); } }); I can think of some really extreme solutions such as going through every single controls in the form an attach the above function to them. However, I don't think that's a very neat solution so I am wondering has anyone got a better solution?
Tags (comma-separated)
Save Edits
Cancel