Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > C# .NET stop carriage return/enter key submitting the form

Reply
Thread Tools

C# .NET stop carriage return/enter key submitting the form

 
 
Veronica Bourke
Guest
Posts: n/a
 
      02-16-2005


Hi,

This is really melting my face. I have a .aspx page with a form. I have
submit buttons on the page for different stages. What i really need is
to stop the form submitting when the return/enter key is pressed.

At the moment if you press the enter key it executes the button clicks
which i dont want.

If someone could help i would be mighty grateful.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      02-16-2005
Client side script can solve this problem.

You could use this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Veronica Bourke" <> wrote in message
news:...
>
>
> Hi,
>
> This is really melting my face. I have a .aspx page with a form. I have
> submit buttons on the page for different stages. What i really need is
> to stop the form submitting when the return/enter key is pressed.
>
> At the moment if you press the enter key it executes the button clicks
> which i dont want.
>
> If someone could help i would be mighty grateful.
>
> Thanks
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      02-16-2005
one approach is to trap the enter key event on client side. Read this link
for an approach
http://www.allasp.net/enterkey.aspx

> This is really melting my face.

save that face please.
--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------


"Veronica Bourke" <> wrote in message
news:...
>
>
> Hi,
>
> This is really melting my face. I have a .aspx page with a form. I have
> submit buttons on the page for different stages. What i really need is
> to stop the form submitting when the return/enter key is pressed.
>
> At the moment if you press the enter key it executes the button clicks
> which i dont want.
>
> If someone could help i would be mighty grateful.
>
> Thanks
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Veronica Bourke
Guest
Posts: n/a
 
      02-16-2005

Thank you all for your replies. I was trying to do it client side from
the start but couldnt seem to get it working. I eventually wrote
something that worked. Its an onkeypress event for the body tag and it
goes a little something like this:

onkeypress='if ((event.which ? event.which : event.keyCode) == 13) {
event.keyCode = 0; }'

thanks again


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing the Enter key from submitting a form donpro Javascript 2 11-09-2007 07:33 PM
HELP: [RETURN] key is not submitting form (ASP.NET 2.0) Axel Dahmen ASP .Net 18 05-30-2007 10:21 AM
Submitting the form correctly using the enter key thechaosengine ASP .Net 2 01-10-2005 12:21 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
stop enter key from submitting a form Phil HTML 2 09-13-2003 05:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57