Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trapping Enter Keypress
Message
From
13/10/2006 15:55:39
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
13/10/2006 15:25:31
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01161896
Message ID:
01161903
Views:
15
This message has been marked as the solution to the initial question of the thread.
>I have an ASP.NET webform, and it seems that there is a button on the form that acts as the default button, since when the user presses the enter key, the button click event occurs. Is there anyway to stop that? I want to either make no default button, or trap the user enter keypress.
>
>Thanks in advance,
>Mike

Mike,

Add the following javascript to the page:
function fnTrapKD(btn) {
    if (document.all) {
        if (event.keyCode == 13) {
                event.returnValue=false;
                event.cancel = true;
                if (btn != null) btn.click();
        }
    }
}
And add the following attribute to the FORM tag:
<FORM ...  onkeydown="fnTrapKD()"  />
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform