Button Click when 'Enter' key is pressed
-
Hi Am having a web page with many textboxes and 3 buttons(button1,button2,button3). Since there are many textboxes,the user can enter value in them with no tab order,according to his convenience. My requirement is that -- Wherever the cursor is focussing(any of the textboxes),when the user clicks 'Enter' key,it should activate the Button1's Click event. Can anyone help me how to do this? Thanks!
-
Hi Am having a web page with many textboxes and 3 buttons(button1,button2,button3). Since there are many textboxes,the user can enter value in them with no tab order,according to his convenience. My requirement is that -- Wherever the cursor is focussing(any of the textboxes),when the user clicks 'Enter' key,it should activate the Button1's Click event. Can anyone help me how to do this? Thanks!
Trap keypress 13
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
Trap keypress 13
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
Thanks Deepak I tried like this...
function buttonClick() { if ((window.event.which == 13) || (window.event.keyCode == 13)) { document.getElementById('btnDisplay').click(); return true; } else return false; }
And in Code behind, i tried asHtmlForm form1 = (HtmlForm)Page.FindControl("Form1"); form1.Attributes.Add("onkeydown","javascript:buttonClick()");
Is this correct ? In which event actually i need to call the Javascript? Please help me! -
Thanks Deepak I tried like this...
function buttonClick() { if ((window.event.which == 13) || (window.event.keyCode == 13)) { document.getElementById('btnDisplay').click(); return true; } else return false; }
And in Code behind, i tried asHtmlForm form1 = (HtmlForm)Page.FindControl("Form1"); form1.Attributes.Add("onkeydown","javascript:buttonClick()");
Is this correct ? In which event actually i need to call the Javascript? Please help me!the logic is right but thw way u implemented is not right..... do one thing
function buttonClick() { if ((window.event.which == 13) || (window.event.keyCode == 13)) { alert("Got U!!") return true; } else return false; } function OnPageLoad() { document.getElementById("Button").onkeydown=buttonClick; document.forms["FORM_NAME"].onkeydown=buttonClick; }
-
the logic is right but thw way u implemented is not right..... do one thing
function buttonClick() { if ((window.event.which == 13) || (window.event.keyCode == 13)) { alert("Got U!!") return true; } else return false; } function OnPageLoad() { document.getElementById("Button").onkeydown=buttonClick; document.forms["FORM_NAME"].onkeydown=buttonClick; }