Postback after carriage return input

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
 
G

Giscard

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">
 
K

Kevin Spencer

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.
 
F

Ferdi

-----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
 
J

Jacob Yang [MSFT]

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.
 
J

Jacob Yang [MSFT]

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.
 

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,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top