Thursday, March 29, 2012

Setting onMouseOver and onMouseOut on dynamic objects

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="hide_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)You may want to try looking at the myHyperLink object for example, it should
have an Attributes collection. This will then render the contents in the tag
when returned to the browser.
myHyperLink.Attributes("onMouseOver") = "show_message(id);"
myHyperLink.Attributes("onMouseOut") = "hide_message(id);"
You will need to change it to specify what "id" is. But this is how you
generally do it.
Hope this helps.
Chris
"Robson Carvalho Machado" wrote:

> 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="hide_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)
>
>

0 comments:

Post a Comment