Click here to Skip to main content
12,553,962 members (63,641 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET .NET4
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 7-Aug-12 15:41pm
Wes Aday 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?
Not a question, anyway. This is a Questions & Answers forum. If CodeProject introduces "requirements" forum, I'll gladly notify you... :-)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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"

ASP.NET DefaultButton Property[^]
Sample usage of Default button[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161021.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100