We are using Sharepoint 2007 In which on master page we have Asp Image button. We want to set this image button as default button for enter key press. We tried some ways but not getting success.
We are using Sharepoint 2007 In which on master page we have Asp Image
Share
Turned out more complicated than I thought but possible nonetheless. First of all, make sure the ID of your control is static:
Now what you need is the following JavaScript code in your
.aspxor.masterpage:You just need to define the real ID as the value of
DEFAULT_BUTTON_IDand the code will automatically attach keypress event to all inputs (text, checkbox and radio) and when Enter is pressed, the button defined as default will get clicked.As you’re using SharePoint is means
window.onloadis already in use so we must add our own event not override it.