Postback after carriage return input

  • Thread starter Thread starter Ferdi
  • Start date Start date
F

Ferdi

I have a WebForm with one control: A HTML INPUT control
with the property "runat=server" set. If this page is
running and I set the cursor in this control and
enter "Carriage return", the page does a roundtrip
(postback) to the server (which I doesn't want). If I
include a second HTML INPUT control on this page,
entering "Carriage return" does no postback.

How can I prevent a postback, if the user enters "CR"?

Thanks for an answer.

Ferdi
 
Ferdi said:
I have a WebForm with one control: A HTML INPUT control
with the property "runat=server" set. If this page is
running and I set the cursor in this control and
enter "Carriage return", the page does a roundtrip
(postback) to the server (which I doesn't want). If I
include a second HTML INPUT control on this page,
entering "Carriage return" does no postback.

How can I prevent a postback, if the user enters "CR"?

Thanks for an answer.

Ferdi

You shouldn't stop this functionality, because it is common
functionality in web browsers, users expect this behavior.

You can however stop it by doing <input type="text" onkeydown="return
event.keyCode==13">
 
You shouldn't stop this functionality, because it is common
functionality in web browsers, users expect this behavior.

It may be a common functionality in web browsers, but it can play havoc with
an ASP.Net WebForm. It is important to anticipate and handle this event.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
-----Original Message----- behavior.

It may be a common functionality in web browsers, but it can play havoc with
an ASP.Net WebForm. It is important to anticipate and
handle this event.

In reality my WebForm needs, in addition to a few
listboxes and textboxes, several buttons to execute
different functions on the server. The return key will do
a click event on the first button (what ever the first
button is), but this is not what the user wanted to do.
The only solution to overcome this problem is to use HTML-
buttons instead of Server-buttons. Is there a better
solution for that problem?

Ferdi
 
Hi Ferdi,

Based on my research and experience, I do not think that there is a better
solution.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Ferdi,

I have another simple idea for your reference. That is disable the
onkeydown event of this button. The following is the code snippet:

<INPUT id="Button2" style="Z-INDEX: 102; LEFT: 248px; WIDTH: 88px;
POSITION: absolute; TOP: 96px; HEIGHT: 24px"
type="button" value="HTML Control" name="Button2" runat="server"
onkeydown="return false"></FONT>

Does it answer your question? If I have misunderstood your concern, please
let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top