ASP Image BorderColor Change on mouseover

Posted on 2009-04-29
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?  
Question by:atuccillo
    LVL 39

    Expert Comment

    by:Pratima Pharande
    try this

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

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

    Accepted Solution

    Hi borderColor,
    Almost there, javascript is case-sensitive.
        thumbnail01.Attributes.Add("onmouseover", "'Red';");

    LVL 29

    Expert Comment

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

    Expert Comment

    Instead try using JQuery

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now