mouseovers

  • Thread starter Thread starter Peter Morris
  • Start date Start date
P

Peter Morris

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.EventArgs)
Handles Me.Load

Me.lnk_introduction.Attributes.Add("onmouseover",
"lnk_introduction.imageurl =
'~/Images/Buttons/button_introduction_over.gif'; ")

End Sub
 
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.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs)
' Me.lnk_introduction.Attributes.Add("onmouseover", _
' "this.src='Images/Buttons/button_introduction_over.gif'; ")
lnk_introduction.Attributes.Add("onmouseover", _
"this.src='http://www.gc.ca/images/francaisbt.gif'")
lnk_introduction.Attributes.Add("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>Mouseover image and mouseout</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:image id="lnk_introduction" runat="server"
imageurl="http://www.gc.ca/images/englishbt.gif" />
</div>
</form>
</body>
</html>
 
Ken Cox said:
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.
 
Back
Top