Running Javascript from an Imagebutton

  • Thread starter Thread starter John
  • Start date Start date
J

John

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 said:
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")
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top