Running Javascript from an Imagebutton

Discussion in 'ASP .Net' started by John, Oct 17, 2004.

  1. John

    John Guest

    Hi all,

    How do I run some Javascript code from an Imagebutton?

    I place the Javascript code inn the onclick in my html section but IE is not
    running it.

    Regards
    John.
     
    John, Oct 17, 2004
    #1
    1. Advertising

  2. John

    Jos Guest

    John wrote:
    > Hi all,
    >
    > How do I run some Javascript code from an Imagebutton?
    >
    > I place the Javascript code inn the onclick in my html section but IE
    > is not running it.
    >
    > Regards
    > John.


    You need to use the Attributes collection, because ASP.NET
    is overwriting the onclick on the button to generate the
    postback.

    myImgBtn.Attibutes.Add("onclick","javascript code goes here")

    --

    Jos
     
    Jos, Oct 17, 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. SamIAm
    Replies:
    0
    Views:
    453
    SamIAm
    Oct 29, 2003
  2. JIM

    Asp:Imagebutton and javascript

    JIM, Mar 18, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    8,669
    Bob Barrows [MVP]
    Mar 18, 2005
  3. JIM

    asp:ImageButton and javascript

    JIM, Mar 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    505
    Bruce Barker
    Mar 19, 2005
  4. K B
    Replies:
    1
    Views:
    564
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Jan 9, 2007
  5. JIM

    asp:ImageButton and javascript

    JIM, Mar 18, 2005, in forum: ASP General
    Replies:
    1
    Views:
    162
    Bruce Barker
    Mar 19, 2005
Loading...

Share This Page