mouseovers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Morris

    #1

    mouseovers

    Newbie here. Trying to get the imageurl of a link to change on mouseover.
    I'm using the following code :

    -----------------------------------------------
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
    Handles Me.Load

    Me.lnk_introduc tion.Attributes .Add("onmouseov er",
    "lnk_introducti on.imageurl =
    '~/Images/Buttons/button_introduc tion_over.gif'; ")

    End Sub
    -------------------------------------------------


    This isn't working. The image does not change. What am I doing wrong?





  • Ken Cox [Microsoft MVP]

    #2
    Re: mouseovers

    Hi Peter,

    You're using server-side syntax for client-side code which doesn't work. For
    example, on the client, the "src" points to the image, not "imageurl".
    Likewise, the use of "~" is meaningless on the client. Here's an example
    that should get you going. Let us know if it helps>

    Ken
    Microsoft MVP [ASP.NET]


    <%@ Page Language="VB" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

    <script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As System.EventArg s)
    ' Me.lnk_introduc tion.Attributes .Add("onmouseov er", _
    ' "this.src='Imag es/Buttons/button_introduc tion_over.gif'; ")
    lnk_introductio n.Attributes.Ad d("onmouseover" , _
    "this.src='http ://www.gc.ca/images/francaisbt.gif' ")
    lnk_introductio n.Attributes.Ad d("onmouseout ", _
    "this.src='http ://www.gc.ca/images/englishbt.gif'" )

    End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Mouseove r image and mouseout</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:image id="lnk_introdu ction" runat="server"
    imageurl="http://www.gc.ca/images/englishbt.gif" />
    </div>
    </form>
    </body>
    </html>


    "Peter Morris" <nospam.ple@sew rote in message
    news:HnhIg.9589 $r61.1354@text. news.blueyonder .co.uk...
    Newbie here. Trying to get the imageurl of a link to change on mouseover.
    I'm using the following code :
    >
    -----------------------------------------------
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArg s)
    Handles Me.Load
    >
    Me.lnk_introduc tion.Attributes .Add("onmouseov er",
    "lnk_introducti on.imageurl =
    '~/Images/Buttons/button_introduc tion_over.gif'; ")
    >
    End Sub
    -------------------------------------------------
    >
    >
    This isn't working. The image does not change. What am I doing wrong?
    >
    >
    >
    >
    >

    Comment

    • Peter Morris

      #3
      Re: mouseovers


      "Ken Cox [Microsoft MVP]" <BANSPAMkjopc@n ewsgroups.nospa mwrote in message
      news:OKTV5EeyGH A.5048@TK2MSFTN GP05.phx.gbl...
      Hi Peter,
      >
      You're using server-side syntax for client-side code which doesn't work.
      For example, on the client, the "src" points to the image, not "imageurl".
      Likewise, the use of "~" is meaningless on the client. Here's an example
      that should get you going. Let us know if it helps>
      >
      Ken
      Microsoft MVP [ASP.NET]

      Yes, got it working due to your help. Thanks a lot.


      Comment

      Working...