javascript command to implement button control

Discussion in 'ASP .Net' started by Steve, May 28, 2006.

  1. Steve

    Steve Guest

    asp.net 2.0

    I have a simple button control which implements some page behind code
    when it is clicked.

    I am looking for a simple javascript command which will in effect cause
    a click on the button. i.e. act as if someone has clicked on the
    button. i.e. do the same thing.

    I will be calling this javascript command from another normal html
    button on the page where I can't use asp.net. I know it seems like a
    strange request, but there is a good reason for it.

    Can anyone help?
    Steve, May 28, 2006
    #1
    1. Advertising

  2. document.getElementById('IdOfTheButtonToClick').click();

    Steve wrote:
    > asp.net 2.0
    >
    > I have a simple button control which implements some page behind code
    > when it is clicked.
    >
    > I am looking for a simple javascript command which will in effect cause
    > a click on the button. i.e. act as if someone has clicked on the
    > button. i.e. do the same thing.
    >
    > I will be calling this javascript command from another normal html
    > button on the page where I can't use asp.net. I know it seems like a
    > strange request, but there is a good reason for it.
    >
    > Can anyone help?
    >
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, May 28, 2006
    #2
    1. Advertising

  3. Steve

    Steve Guest

    Excellent. Thank you so much for that Goran. It really helped me out a
    lot. :)
    Steve, May 28, 2006
    #3
  4. Laurent Bugnion, May 28, 2006
    #4
  5. Laurent Bugnion wrote:
    > Hi,
    >
    > Göran Andersson wrote:
    >
    >> document.getElementById('IdOfTheButtonToClick').click();

    >
    >
    > To be complete, this does not work in Firefox.


    Of course it does. My wrong, sorry. I tested using a button with a
    "name", but without an "id", and document.getElementById fails in
    Firefox (which is correct). However it succeeds in IE (wrongly).

    So to summarize, click() is also available in Firefox.

    Sorry about the confusion.

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
    Laurent Bugnion, May 28, 2006
    #5
    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. Replies:
    0
    Views:
    492
  2. llandre
    Replies:
    2
    Views:
    286
    sturlamolden
    Mar 22, 2008
  3. prakash
    Replies:
    2
    Views:
    569
    prakash
    Apr 11, 2005
  4. Jim Gilligan
    Replies:
    0
    Views:
    149
    Jim Gilligan
    Sep 1, 2005
  5. Sam Kong
    Replies:
    1
    Views:
    110
    Sami Samhuri
    Jun 21, 2007
Loading...

Share This Page