Key press "Enter" does not submit the form

Discussion in 'ASP .Net' started by Andrea Williams, May 24, 2004.

  1. I've created a simple search form and a submit button. On click of the
    button, I have code-behind that runs and fills a datagrid. However, it the
    person is focused on one of the other controls and presses the "Enter"
    button, my submit button event code doesn't fire so my datagrid is either
    empty, or it shows a lot of blank rows. It looks like the submit happened,
    but since my code to fill the datagrid is in the submit_click method, it's
    not executed.

    So how can I get the "Enter" button to execute the event method for the
    submit button? Is there a way to handle the key press event and make it run
    the submit_click method?

    Thanks,
    Andrea
    Andrea Williams, May 24, 2004
    #1
    1. Advertising

  2. You can intercept the client side enter keypress event of the text box and
    then do what you want using javascript code.
    Here's a good example:
    http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18

    You could also try using this free control.
    http://www.metabuilders.com/tools/DefaultButtons.aspx

    And here's 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


    "Andrea Williams" <> wrote in message
    news:...
    > I've created a simple search form and a submit button. On click of the
    > button, I have code-behind that runs and fills a datagrid. However, it

    the
    > person is focused on one of the other controls and presses the "Enter"
    > button, my submit button event code doesn't fire so my datagrid is either
    > empty, or it shows a lot of blank rows. It looks like the submit

    happened,
    > but since my code to fill the datagrid is in the submit_click method, it's
    > not executed.
    >
    > So how can I get the "Enter" button to execute the event method for the
    > submit button? Is there a way to handle the key press event and make it

    run
    > the submit_click method?
    >
    > Thanks,
    > Andrea
    >
    >
    Steve C. Orr [MVP, MCSD], May 24, 2004
    #2
    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. Megha Vishwanath
    Replies:
    2
    Views:
    9,819
    tutorialsmaster
    Oct 2, 2009
  2. WJ
    Replies:
    1
    Views:
    3,882
    Adrienne
    Jan 19, 2005
  3. gnewsgroup
    Replies:
    0
    Views:
    492
    gnewsgroup
    Dec 27, 2007
  4. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    388
    Anders Matthiessen
    Jan 12, 2005
  5. Megha Vishwanath
    Replies:
    3
    Views:
    699
    Megha Vishwanath
    Jul 20, 2004
Loading...

Share This Page