Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .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 16:41pm
Comments
Wes Aday at 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 at 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
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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"
    defaultbutton="SubmitButton"
    defaultfocus="TextBox1"
    runat="server">
 
Refer:
ASP.NET DefaultButton Property[^]
Sample usage of Default button[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2014
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