Image button acting like submit button.

Discussion in 'ASP .Net' started by Russell, Jun 23, 2004.

  1. Russell

    Russell Guest

    I have a web page that i am using an image button as my submit button. The
    code behind the button works, but when I click enter on the web page,
    nothing happens. Can anybody tell me how to get my image button to act as
    the default button on the form?

    Thanks in advance
    Russell
     
    Russell, Jun 23, 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


    "Russell" <> wrote in message
    news:...
    > I have a web page that i am using an image button as my submit button. The
    > code behind the button works, but when I click enter on the web page,
    > nothing happens. Can anybody tell me how to get my image button to act as
    > the default button on the form?
    >
    > Thanks in advance
    > Russell
    >
    >
     
    Steve C. Orr [MVP, MCSD], Jun 23, 2004
    #2
    1. Advertising

  3. Russell

    Eric Cherng Guest

    Russell,

    I've had this problem before too and, to my knowledge at least, there is no
    direct way to achieve this. Instead what I did was provide a handler for
    the text box that handles the enter key. If the handler gets called, it
    just forwards the processing to the image button's submit handler. This
    solution isn't exactly the most elegant way, but it works.

    Eric


    "Russell" <> wrote in message
    news:...
    > I have a web page that i am using an image button as my submit button. The
    > code behind the button works, but when I click enter on the web page,
    > nothing happens. Can anybody tell me how to get my image button to act as
    > the default button on the form?
    >
    > Thanks in advance
    > Russell
    >
    >
     
    Eric Cherng, Jun 23, 2004
    #3
  4. It's very strange that in my project, they automatically act as a submit
    button, so I have to add a (X,Y) = (0,0) checker in the click handler
    routine just to skip when "enter" is pressed in the textbox.

    Perheps there are more than one ImageButton in your form so the browser got
    it mixed up.

    "Eric Cherng" <ericch1@remove_the_dot-hotmai.l.com> ¦b¶l¥ó
    news:% ¤¤¼¶¼g...
    > Russell,
    >
    > I've had this problem before too and, to my knowledge at least, there is

    no
    > direct way to achieve this. Instead what I did was provide a handler for
    > the text box that handles the enter key. If the handler gets called, it
    > just forwards the processing to the image button's submit handler. This
    > solution isn't exactly the most elegant way, but it works.
    >
    > Eric
    >
    >
    > "Russell" <> wrote in message
    > news:...
    > > I have a web page that i am using an image button as my submit button.

    The
    > > code behind the button works, but when I click enter on the web page,
    > > nothing happens. Can anybody tell me how to get my image button to act

    as
    > > the default button on the form?
    > >
    > > Thanks in advance
    > > Russell
    > >
    > >

    >
    >
     
    Lau Lei Cheong, Jun 24, 2004
    #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. Rob Heersma

    classes acting like instances

    Rob Heersma, Feb 5, 2004, in forum: XML
    Replies:
    0
    Views:
    382
    Rob Heersma
    Feb 5, 2004
  2. mcsejung
    Replies:
    2
    Views:
    302
    Marc 'BlackJack' Rintsch
    Feb 22, 2008
  3. Replies:
    4
    Views:
    1,237
    Adrienne Boswell
    Mar 23, 2010
  4. Mike Mr.
    Replies:
    4
    Views:
    218
    Mike Jo
    Sep 21, 2008
  5. D'Anne Asquith

    Numbers not acting like numbers

    D'Anne Asquith, Oct 1, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    105
    Heinrich Mislik
    Oct 2, 2003
Loading...

Share This Page