Link to home
Start Free TrialLog in
Avatar of atuccillo
atuccillo

asked on

ASP Image BorderColor Change on mouseover

I'm writing a .NET website using c#.  I am making a photo gallery and have the images within asp:Image components.  Here is the code for the components:
<asp:Image ID="thumbnail01" runat="server" BorderColor="Green" BorderWidth="2px" />

On mouseover, I want the image border color to change.  I tried this with no luck:
thumbnail01.Attributes.Add("onmouseover", "document.getElementById(thumbnail01').BorderColor='Red'");

I also tried this with no luck:
thumbnail01.Attributes.Add("onmouseover", "document.getElementById('thumbnail01').style.BorderColor='Red'");

And this:
thumbnail01.Attributes.Add("onmouseover", "this.BorderColor='Red'");

I also tried doing it through a stylesheet with no luck  What am I missing here?  Is there a special way to reference a BorderColor in an asp:Image?  
Avatar of Pratima
Pratima
Flag of India image

try this

  thumbnail01.Attributes.Add("onmouseover", "document.getElementById('thumbnail01').style.borderColor='Red'");

Javascript is Case Sensative
so change BorderColor  to  borderColor as shown above
ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooopps, too late after enter the comment...
Instead try using JQuery
http://www.dotnetcube.com/post/Getting-started-with-JQuery-in-ASPNET.aspx

This way you can make it reusable and much more intuitive - easy to implement.