Connecting Tech Pros Worldwide Forums | Help | Site Map

please anybody help to solve keydown event for enter button problem

Newbie
 
Join Date: Jan 2007
Posts: 7
#1: Mar 8 '07
Hi,


I am working in asp.net with C# web application, i have used one textbox and image button for search

funtion, i have created one user control for this, but after i have entered value in textbox, i have pressed the

button, its not at all working, if i will use mouse i can able to search values, how to enable to enter key at

keydown event of textbox, the following script i have used ,


function Buttonfocus()
{
if(event.which || event.keyCode)
{
if ((event.which == 13) || (event.keyCode == 13) || (event.which == 10) || (event.keyCode == 10))
{
document.getElementById("go").click();
return false;
}
}
else
{
return true;
}
}

Please anybody to help me solve this problem in my application, advanced thanks for any reply.

Thanks.

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Mar 8 '07

re: please anybody help to solve keydown event for enter button problem


See this page for a cross-browser way of accessing event properties.

You need to have an argument in the function for this to work in all (most) browsers.
Reply