Click here to Skip to main content
15,915,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two buttons on my page.
One button is 'Submit' button and one button is 'Cancel' button.

I want to use the 'tab' button and the 'enter' button in addition to using mouse.

After clicking tab, when control is on 'submit' button, the click of 'enter' button should raise the submit event. On clicking tab, when control is on 'Cancel' button, the click of 'enter' button should raise the Cancel event.

When I browse the net, I see examples of using panel and default button, however I need more that default button.
Depending upon which button the control is on, hitting enter button should appropriately call the event of that button.

Regards,
NetQuestions
Posted
Updated 15-Dec-10 22:10pm
v2
Comments
[no name] 5-Dec-10 10:53am    
Please clarify. If cancel button has focus you want to click the submit button?
Dalek Dave 16-Dec-10 4:10am    
Edited for Grammar and Readability.

hi,
just place an asp panel in the form ..make it sure that the whole control including the buttons are inside the panel..then set the default button as ur submit button..
Hope this may help you..
 
Share this answer
 
v2
when control is on 'submit' button, the click of 'enter' button should raise the submit event.
when control is on 'Cancel' button, the click of 'enter' button should raise the Cancel event.


This IS the normal behavior and you don't need to write any code for it. On pressing enter, default event of the control having the focus is executed.

What you read about panels and default button is about having a default focus on page load. If you are using tab explicitly to focus on buttons then you dont need this default button feature. Once your focus is on 'submit' button, pressing enter would raise submit button click event. Similarly, once you shift your focus to 'cancel' button and press enter - it would raise cancel button click event.
 
Share this answer
 
Sandeep, for some reason this is not working.

Is this because I have a timer control on the update panel?

Could it be that because I have timer, even if I tab and focus is on 'Submit' button, the focus gets lost?

If I press enter some 5 to 6 times, in one of the attempt it will work!!!
Regards,
Maneesh Menon
 
Share this answer
 
Comments
Toniyo Jackson 16-Dec-10 5:19am    
Don't write your comments here. You have add comment button below all answers. so write your comments below the appropriate 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