Urgent: How can I get the enter key to behave like a tab key?

K

Karen Grube

Hi!

I have a web form completely filled with about 80 server-side controls
(text boxes - single line and multiline - and drop downs). The enter key is
firing the submit button rather than taking the user to the next tabindexed
field.

Users should be able to use the tab key or the enter key to navigate
from one box to the next. All I've been able to find in my research is how
to do this using client controls or windows forms, not asp.net web forms
using server controls.

At this point, I'm lost. I can't find an "onkeypress" or "onkeydown"
event for server controls that I can send to a little javascript function
that will change the enter key into a tab - or anything even related to that.
That's the technique most often recommended, but it doesn't seem to work
with server controls.

Help, please!

Thanks!
Karen Grube
(e-mail address removed)
 
K

Karen Grube

Hi!

I just learned about a bug in asp.net that raises the postback event on
the first enabled button control when the enter key is pressed in a textbox
control that causes a autoposback. The kb article numberis 813822. The only
problem is that the so-called solution makes no sense to me, and it sitll
won't handle all the other textboxes on the page that DON'T need to do a
postback.

This is really bad! I can't give my users this application with the
enter key working this way. I need a solution badly. I'd love to completely
disable the enter key, but there are a couple of multi-line text boxes that
may need it.

All I want is for the enter key NOT to execute any events associated with
buttons on the page. I just want it to move to the next control on the page.
That's not quite true. If the user has tabbed down to either of the the
buttons, I guess the enter key pressed on the submit or reset buttons
themselves would be okay, but NOWHERE else on the page.

Is there some kind of event handler out there that will help? Something?
Anything?

Please help!!

Thanks!
Karen
 
H

haile

Karen:

Get rid of all the submit buttons. I know that sounds counterintuitive, but
it is not as hard as you might think. The page doesn't really need them.
Set up a fake "submit" button like this:

<asp:button runat=server id="btnFakeSubmit" text="Submit"></asp:button>

In design view, add a click handler called "btnFakeSubmit_Clicked". The
event handler will be added to InitComponent() automatically, and you should
be taken to the new handler:

private void btnFakeSubmit_Clicked(o,e)
{
// process my 80 text boxes.
}

You should find that this button doesn't respond to the "Enter" key. In
fact, if you wanted it to respond to "Enter" (say, by using it in a login
page), you would have to go out of your way to make it happen.

Haile
 
K

Karen Grube

Thank you both so much!! I'm going to try both solutions and see which
one works best for my purposes. I can't tell you how much I appreciate the
response.

Gee, both of these solutions should be in a knowledge base article!!! If
you can forward that suggestion, that would be good.

Thanks!
Karen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top