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

you can use control .Attributes.Add("onmouseover","javascriptfunctionhere");

thanks fior the reply

but I want to do in on clientside scripting

plz help me out

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.