Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

surpressing the enter key

Status
Not open for further replies.

PureDevelopers

IS-IT--Management
Aug 25, 2006
18
US
How do I surpress the enter key from submitting an asp:ImageButton?

<asp:ImageButton ID="CatTopNavigationUp" runat="server" CausesValidation="false" OnClick="CatTopNavigationUp_Click" AlternateText="Click here to expand this menu" ImageUrl="Images/CatTopNavigationUp.gif" />


I am using this image to control a collapsable menu in the master page which is used on all pages on my site. I also have a login page which has a submit button. No matter what I do, I can't seem to surpress the enter key from triggering the image button.
I use a default button on the login page, but if I load the page and click on some arbitrary part of the page and then hit enter, the imageButton is getting submitted instead of the form submit button.
 
Check the window.event.keycode in javascript. I believe its 13 for enter. If the keycode is 13 return false.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top