Sunday, February 18, 2007

Enter key Navigation and 2.0

there are two ways of getting to navigate with the enter key. one is using the panel control's property "DefaultButton".

another method, is to use the onkeydown event of the body element to detect the enter key "keycode=13".
here's the function that would detect the enter key:
>> body onkeydown='ManageKeyDown'
function ManageKeyDown(e)
var code;
if(window.event) // for IE
code= e.keyCode;
else if(e.which) // for Netscape/Firefox/Opera
code= e.which;
if (code== 13) // if it's the enter key
//here goes the implentation necessary to execute a button

this is another way, which is a bit more flexible, and works with ajax. while the defaultButton property of a panel may not work with the update panel (from my experience with this technique).

comments welcome

No comments: