Executing Javascript from a web toolbar button

J

John

Hi all,

I have a web toolbar and a few buttons on it. On one of the buttons, I need
to execute some Javascript. I did put <span
onclick="Javascript:alert('test');"></span> in the text property but this
does not work.

How can I execute some Javascript from one of these buttons?

Regards
John.
 
G

Guest

Hi,
I tried the same code ( SPAN tag on click), it works fine. can u post the
exact
code, so we can get a clear picture.

Thanks,
Senthil.
 
J

John

Hi Senthil,

Here is the code:
Dim override As Microsoft.Web.UI.WebControls.ToolbarButton =
toolClaim.Items.Item(2)

override.ImageUrl = Session("ImagePath") & "override.jpg"

override.ToolTip = "Override"

override.Text = "<span onclick=""alert('Tester');""></span>"





Now the ImageURL as well as the ToolTip is working fine. I can see the span
section if I 'view source' on the html page but it doesn't execute. I know
it's not security settings since I have alerts that work throughout my app.

Any help appreciated . . .

Regards
John.
 
R

Ryden

Try this instead:

override.ImageUrl = Session("ImagePath") & "override.jpg"

override.ToolTip = "Override"

'override.Text = "<span onclick=""alert('Tester');""></span>"

override.Attributes("onclick") = "alert('Tester');"

override.onClick is the ASP event, wherea
override.Attributes("onclick") is the tag attribute usable t
JavaScript

This is a much cleaner approac


-
Ryde
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top