Disable Return key outside textareas on a Asp.Net web page (containing ajax code)

Posted by Achim on Stack Overflow See other posts from Stack Overflow or by Achim
Published on 2009-11-24T13:32:42Z Indexed on 2010/04/16 20:53 UTC
Read the original article Hit count: 526

Filed under:
|
|
|

Hi,

I have an Asp.Net web page, having the common Asp.Net form. The outer "border" of the page (i.e. main menu, header, ...) is build using normal Asp.Net code using a master page. The content of that page uses jQuery to display dynamic forms and to send data to the server.

If I push the return key on that page, I jump to a (more or less) random page - which is not what the user expects. ;-)

There are some text areas and the user must be able to enter line breaks. Otherwise it would be fine to disable the return key completely. Any bullet proof way to do that?

I found some solutions on the web, which capture the keypress event and ignore \x13, but that does not really work. It works as long as the page has just loaded, but as soon as I have clicked on some elements, the return key behaves as usuall.

Any hint would be really appreciated!

Achim

© Stack Overflow or respective owner

Related posts about routed-events

Related posts about AJAX