Setting onMouseOver and onMouseOut on dynamic objects

Discussion in 'ASP .Net Web Controls' started by Robson Carvalho Machado, Aug 18, 2004.

  1. 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)
     
    Robson Carvalho Machado, Aug 18, 2004
    #1
    1. Advertising

  2. 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

    "Robson Carvalho Machado" <>
    wrote in message news:D...
    > 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)
    >
    >
    >
    >
     
    Mark Fitzpatrick, Aug 19, 2004
    #2
    1. Advertising

  3. Dear Mark,

    Thaks a lot.

    "Mark Fitzpatrick" wrote:

    > 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
    >
    > "Robson Carvalho Machado" <>
    > wrote in message news:D...
    > > 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)
    > >
    > >
    > >
    > >

    >
    >
    >
     
    Robson Carvalho Machado, Aug 19, 2004
    #3
    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. Tor Inge Rislaa
    Replies:
    3
    Views:
    16,179
    Jerry III
    Aug 6, 2003
  2. Kurda Yon
    Replies:
    1
    Views:
    730
    Andy Dingley
    Feb 10, 2008
  3. Dave
    Replies:
    0
    Views:
    481
  4. Neredbojias

    Re: onMouseOver and onMouseOut

    Neredbojias, Sep 9, 2010, in forum: HTML
    Replies:
    0
    Views:
    527
    Neredbojias
    Sep 9, 2010
  5. Shawn Windle

    onMouseover and onMouseout problems

    Shawn Windle, Sep 1, 2003, in forum: Javascript
    Replies:
    0
    Views:
    93
    Shawn Windle
    Sep 1, 2003
Loading...

Share This Page