Monday, 28 May 2012

Image Mouse Hover in asp.net


To show image in particular div when mouse hover on the image using asp.net

  Script

<script type="text/javascript" language="javascript">

        function ShowToolTip(con) {
            document.getElementById("div_img").style.visibility = "visible";
            document.getElementById("img_tool").src = con.src;
            document.getElementById("div_img").style.left = event.clientX;
            document.getElementById("div_img").style.top = event.clientY;
            document.getElementById("div_img").style.zIndex = "0";
        }

        function hideToolTip() {
            document.getElementById("div_img").style.visibility = "hidden";
        }

    </script>

Note:write this script in head tag


Design:


<form id="form1" runat="server">
    <div>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/3.jpg" Height="50px" Width="50px"
            onmouseover="ShowToolTip(this);" onmouseout="hideToolTip();" />
            <br />
            <br />
        <div id="div_img" style="height: 300px; width: 300px; border: solid 1px black; position: absolute;
            visibility: hidden;">
            <img id="img_tool" height="100%" width="100%" />
        </div>
    </div>
    </form>

Final Output:




1 comments:

  1. It is very good blog and useful for students and developer , Thanks for sharing



    .Net Online Training

    ReplyDelete