473,775 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing Enter Key

I'm developing a website using visual studio .NET

I have a login form with a couple of textboxes and a login button. What I
want to do is capture the Enter key so that when the user presses Enter, it
will click the submit button.

I have searched the Internet for hours now trying to find out how to do it,
but any methods that I have seen do not work.

Can anyone help me do that?
Dec 29 '05 #1
3 1747
If your login button is just an <input type="submit" .../>, then I
would expect it to respond to enter automatically. If, however, you are
using ASP textbox controls, then problems seem to occur, particularly
on esoteric browsers. If you are using an asp:HtmlButton or
asp:HtmlInputBu tton, you could try using an asp:Button instead, as
that's more likely to work. If that doesn't help, I would try adding a
(client-side) onkeydown event that checks for character 13 (return),
and if it detects it, calls the form's submit method.

It'd be helpful if you could post the code for the page in question,
though [and perhaps say what are the sorts of methods that did not
work...].

Dec 29 '05 #2
Never mind!!! I found a way using Javascript
Dec 29 '05 #3
Well, there were too many things I had tried in order to capture the Enter
Key. In the end, I used this javascript:

<SCRIPT>

if (document.layer s)
document.captur eEvents(Event.K EYDOWN);

document.onkeyd own = function (evt)
{
var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) :
event.keyCode;

if (keyCode == 13)
{
document.Login1 470.cmdSubmit.c lick();
return false;
}
else
return true;
};

</SCRIPT>

It works like a charm.
Dec 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10565
by: coolsti | last post by:
Can someone help me enhance this code snippet which works only for IE so that it will also work for Firefox? I have been trying all sorts of things and have gotten to where I can capture the keydown and keypress events in Firefox, but then I can't seem to get the key code. I also don't know if the window.event.srcElement.type works with Firefox or if the onkeydown="return false" is valid in Firefox. I have this Javascript at the end of...
7
20372
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common browsers? The script bellow is IE only. It fails FF 1.0 and NN 7. Also, if I can trap the keypress I would like to use it to tab to the next tabindex.
3
2018
by: Norma | last post by:
I am trying to capture data in a date parameter query that spans from 1 to 3 months. I have a field that is a checkbox that notes whether or not this data is 'red flagged' (so you know, the red flagged data is end of the month production that is reported in the following months report) I need to capture the red flagged production from the previous month and the production from the entered month(s) not including the red flagged production...
4
15392
by: Vazz | last post by:
I am trying to capture the key combination "Control + Shift + Enter" in a KeyDown event. I am able capture "Control + Enter" using (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I check if there are two Modifiers?
14
2551
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the internet, they have to login. I want to be able to capture that login versus their Windows login because I need to know who they are from any computer rather than only their computer. Any ideas? Thanks
4
1424
by: Steve Wolfie | last post by:
Hello all: Again, let me thank everyone who has helped in the past. Can't wait till I can help out with some advice of my own. Now, I am building an app that wishes to retrieve the output of Google Desktop. It is very simple, I wish to send an http request asking for the results in XML. ( by adding &format=xml to the end of the url) i would like to capture the response from the Google Desktop server, (on the local machine) and save...
4
1545
by: alien2_51 | last post by:
I have a form with several buttons, I'd like to default to a specific button on the Enter keypress event, How would I do this...?
2
2651
by: Malt via AccessMonster.com | last post by:
Hi; I would like to place a date range in a report header that matches the input dates a user enters through a parameter query when the report is run. The query contains the following in the date field criteria: Between And . Does anyone have any suggestions? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200709/1
3
1572
by: qf2bb | last post by:
I have a textbox where the user can enter a value and then hit an update button. The users also just want to be able enter the value and hit the enter key. How do I code this for the enter key?
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.