Friday, 22 June 2012

How to Call Method Or Function Or Button From Java Script

Call Method Or Function Or Button From Java Script

                    Actually we can call button from java script and it will lead the post back also 

 Example  :

          First Add This Property to the Page Directory

                        EnableEventValidation="false"

      here:



      
      1) when click on button or any control call java script as below
                
              

       2) the Java script function :


       3) this OK button place in the page like this



       4) so the button OK will call in server side:



         Like this we can call Method Or Function Or Button From Java Script

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: