473,493 Members | 2,245 Online
Bytes | Software Development & Data Engineering Community
Create 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 1727
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:HtmlInputButton, 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.layers)
document.captureEvents(Event.KEYDOWN);

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

if (keyCode == 13)
{
document.Login1470.cmdSubmit.click();
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
10549
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...
7
20356
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...
3
1987
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...
4
15309
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...
14
2511
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...
4
1410
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...
4
1531
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
2635
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...
3
1557
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
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
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,...
0
7195
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...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
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...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
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...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
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...

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.