Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ASP Image BorderColor Change on mouseover

Posted on 2009-04-29
4
Medium Priority
?
584 Views
Last Modified: 2012-05-06
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?  
0
Comment
Question by:atuccillo
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 24266873
try this

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

Javascript is Case Sensative
so change BorderColor  to  borderColor as shown above
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 2000 total points
ID: 24266880
Hi borderColor,
Almost there, javascript is case-sensitive.
eg:
    thumbnail01.Attributes.Add("onmouseover", "this.style.borderColor='Red';");
   

0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24266884
Ooopps, too late after enter the comment...
0
 
LVL 3

Expert Comment

by:RobbP
ID: 24273164
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question