Click here to Skip to main content
15,894,252 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
my requirement is if i press the enter button of key board then fire click event so how to write the code for this application
Posted
Comments
[no name] 7-Aug-12 22:46pm    
Your requirement should be to try to do something for yourself. What have you tried for yourself? Did you even try? What exactly is the problem that you have? Where is the code that demonstrates your problem?
Sergey Alexandrovich Kryukov 8-Aug-12 0:17am    
Not a question, anyway. This is a Questions & Answers forum. If CodeProject introduces "requirements" forum, I'll gladly notify you... :-)
--SA

If you are talking of ASP.NET, you can add "DefaultButton" property for the page.

In ASP.NET 2.0 onwards, it's said to have "Default Button" defined for the page. By simply specifying the "defaultbutton" property to the ID of the <asp:Button>, whose event you want to fire, your job is done.
The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the <asp:panel> definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel

Sample example:
<form id="Form1"
    defaultbutton="SubmitButton"
    defaultfocus="TextBox1"
    runat="server">


Refer:
ASP.NET DefaultButton Property[^]
Sample usage of Default button[^]
 
Share this answer
 
In the Designer, highlight the form the button is in, and set the AcceptButton property to the Login button.
This means that the Enter key will automatically fire it's Click event.
 
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