>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()" />