Setting onMouseOver and onMouseOut on dynamic objects

  • Thread starter Robson Carvalho Machado
  • Start date
R

Robson Carvalho Machado

Dear friends,

Is there a way to set onMouseOver and onMouseOut on dynamic objects?

I need to create two javascript events:
onMouseOver="show_message(id)"
onMouseOut="show_message(id)"

My objects are created as follows:

Dim ID as String

ID = "hyperlink1"
Dim myHyperLink as HyperLink
myHyperLink = New HyperLink
myHyperLink.ID = ID
myHyperLink.ImageUrl = "http://localhost/img.gif"
PlaceHolder1.Controls.Add(myHyperLink)

ID = "image1"
Dim myImage as Webcontrols.Image
myImage = New WebControls.Image
myImage.ID = ID
myImage.ImageUrl = "http://localhost/"
PlaceHolder1.Controls.Add(myImage)

ID = "label1"
Dim myLabel as Label
myLabel = New Label
myLabel.ID = ID
myLabel.Text = "my label"
PlaceHolder1.Controls.Add(myLabel)
 
M

Mark Fitzpatrick

Sure, use the Add method of the attributes collection like so:
myHyperLink.Attributes.Add("onMouseOver","show_message(id)")

Of course, this has to be done before the control is added to the
placeholder.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
R

Robson Carvalho Machado

Dear Mark,

Thaks a lot.

Mark Fitzpatrick said:
Sure, use the Add method of the attributes collection like so:
myHyperLink.Attributes.Add("onMouseOver","show_message(id)")

Of course, this has to be done before the control is added to the
placeholder.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top