473,471 Members | 2,613 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 1726
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
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
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
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
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
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
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
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
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
1
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...
0
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,...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.