how to use in onmouseover and onmouseout property for a ASP.Net2.0 control by using javascript

Suppose I want to show and hide an Image by taking and removing mouse over another control like Image, Label.... by using JavaScript only

I suppose you could just point the onmouseover over property to a function which sets the visbility of the object and loke wise for onmouseout the functions would look something like:

function hideImage(control) {
control.style.visibility = 'hidden';
}

function showImage(control) {
control.style.visibility = 'visible';
}

the properties in the control should look something like: OnMouseOver = "hideImage(this)" OnMouseOut = "showImage(this)"

I haven't tested this though but something like it should work

attribute.add(....) function is for client side only.. and it works fine with grid views...
but in case of asp:buttons i am also having trouble..

This may not be the proper way,but serves the purpose.
When user mouseover on button it displays the image and when on mouseout hides the image.

aspx:

<script  type="text/javascript">
 function ShowImage()
    {
     value=document.getElementById("Image1")
     value.src="Images/Update.gif"
     value.width=15
     value.height=15;
     value.style.visibility ='visible'
    }
 function HideImage()
    {
      value=document.getElementById("Image1")
      value.style.visibility ='hidden'
    }
</script>

 <asp:Button ID="btn" runat="server" Text="Button" />
        
<img id="Image1" src="" alt="image" width="0" height="0" />

aspx.cs

btn.Attributes.Add("onmouseover", "ShowImage()");
 btn.Attributes.Add("onmouseout", "HideImage()");

Good Luck

ravichandra

This question has already been answered. Start a new discussion instead.