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

Discussion in 'ASP .Net Web Controls' started by Veronica Bourke, Feb 16, 2005.

  1. 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!
    Veronica Bourke, Feb 16, 2005
    #1
    1. Advertising

  2. 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/2004/06/asp200406so_f/asp200406so_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!
    Steve C. Orr [MVP, MCSD], Feb 16, 2005
    #2
    1. Advertising

  3. 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!
    Alvin Bruney [MVP], Feb 16, 2005
    #3
  4. 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!
    Veronica Bourke, Feb 16, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thechaosengine
    Replies:
    2
    Views:
    470
  2. Phil
    Replies:
    2
    Views:
    5,058
  3. M P
    Replies:
    1
    Views:
    466
  4. Steve Anderson
    Replies:
    3
    Views:
    251
    Steve Anderson
    Jun 21, 2004
  5. donpro
    Replies:
    2
    Views:
    107
    Bart Van der Donck
    Nov 9, 2007
Loading...

Share This Page