Click here to Skip to main content
15,881,588 members
Articles / Web Development / ASP.NET

Capturing the Enter key to cause a button click

Rate me:
Please Sign up or sign in to vote.
4.92/5 (38 votes)
19 Jan 2007CPOL2 min read 536.8K   2.8K   49  
Have you ever wanted to trap the Enter key press event in ASP.NET and have it click a button for you? This article describes two options for capturing the Enter key press event and then clicking a button. One solution uses JavaScript, the other uses a Panel control.

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnterKeyPressToButton", "EnterKeyPressToButton\EnterKeyPressToButton.csproj", "{FCEE355B-9C39-44FF-9491-7D1DEA08EBC1}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{FCEE355B-9C39-44FF-9491-7D1DEA08EBC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{FCEE355B-9C39-44FF-9491-7D1DEA08EBC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{FCEE355B-9C39-44FF-9491-7D1DEA08EBC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{FCEE355B-9C39-44FF-9491-7D1DEA08EBC1}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
United States United States
I started my programmer career over 26 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with vb.net when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out asp.net in 2004. I achieved my MCSD.net in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between vb.net and C# to be mostly syntax. In my current position I am programming in C# working on WPF and MSSql database stuff. Lately I have been using VS2019.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

Comments and Discussions