By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,743 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,743 IT Pros & Developers. It's quick & easy.

ENTER key falls through to unwanted handlers in Web App

P: n/a
I have some ASP.NET Web App pages on which there are web forms with
textboxes and buttons for 'Cancel' and 'Submit' and such. All works great.
However, it a user uses the ENTER key in either of two textboxes, the
postback 'falls through' to one of the 'Cancel' button handlers, and exits
the application. Oddly, I can't use anything in the Cancel routine to check
whether the ENTER key was hit, since the sender object is always the Cancel
key itself. This behavior is unwanted, and I can't figure out how to trap
the ENTER hey strokes either on the client or server side.

On some pages I have been able to get the ENTER key to fall through to a
Submit button, which makes more sense, but I still would like to be able to
process the postback depending on the ENTER key usage or not.

What approach should I be using?

Bob
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bob,

In the html view of the aspx page, make sure the Submit button appears
before the Cancel button. In that way, the Enter will go to the Submit button.

"Robert Dickow" wrote:
I have some ASP.NET Web App pages on which there are web forms with
textboxes and buttons for 'Cancel' and 'Submit' and such. All works great.
However, it a user uses the ENTER key in either of two textboxes, the
postback 'falls through' to one of the 'Cancel' button handlers, and exits
the application. Oddly, I can't use anything in the Cancel routine to check
whether the ENTER key was hit, since the sender object is always the Cancel
key itself. This behavior is unwanted, and I can't figure out how to trap
the ENTER hey strokes either on the client or server side.

On some pages I have been able to get the ENTER key to fall through to a
Submit button, which makes more sense, but I still would like to be able to
process the postback depending on the ENTER key usage or not.

What approach should I be using?

Bob

Nov 17 '05 #2

P: n/a
Robert Dickow wrote:
I have some ASP.NET Web App pages on which there are web forms with
textboxes and buttons for 'Cancel' and 'Submit' and such. All works
great. However, it a user uses the ENTER key in either of two
textboxes, the postback 'falls through' to one of the 'Cancel' button
handlers, and exits the application. Oddly, I can't use anything in
the Cancel routine to check whether the ENTER key was hit, since the
sender object is always the Cancel key itself. This behavior is
unwanted, and I can't figure out how to trap the ENTER hey strokes
either on the client or server side.

On some pages I have been able to get the ENTER key to fall through
to a Submit button, which makes more sense, but I still would like to
be able to process the postback depending on the ENTER key usage or
not.

What approach should I be using?

Bob


Some background info:
When you hit the enter-key in the browser, that browser simulates a click
on the "default button". The browser then sends a request to the server as if that
button was clicked.
The server then has no way to know *how* that button was clicked. Asp.Net
just registers a "click" on your button.

See www.MetaBuilders.com, look for DefaultButtons. That might help.

Hans Kesting
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.