Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

i would like to find out how to make an asp button to work same as when the enter key is pressed.
I have made the UseSubmitBehavior="true" property, but that doesn seem to do the trick.
Can you please some options?

Thanks.
Posted
Comments
K Herms 8-Dec-11 6:48am    
Do you mean that when you are in a textbox and hit enter, the button click event should be fired?
AnnSJ 8-Dec-11 6:51am    
yes...

you can use the DefaultButton property of the asp:Panel control.
 
Share this answer
 
v2
try this...

JavaScript
function CheckKey() 
{ 
var bt = document.getElementById(buttonid);
 
    // checks whether the ENTER key is pressed 
    if (window.event.keyCode == 13) 
    { 
       // act as though the search button was pressed 
      bt .click(); 
    } 
} 


hope it works...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900