Mouse Position in ASP.NET using JQuery

Below is my code:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MousePosition.aspx.cs" Inherits="MousePosition" %>  
  2.   
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  4. <html xmlns="http://www.w3.org/1999/xhtml">  
  5. <head runat="server">  
  6.     <title>Mouse Position using JQuery in Asp .Net</title>  
  7. </head>  
  8.   
  9. <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>  
  10.   
  11. <script type="text/javascript">  
  12.     $(function() {  
  13.         $(document).mousemove(function(e) {  
  14.             $('#lblMousePosition').html("X Axis: " + e.pageX + "<br/><br/>" + "Y Axis: " + e.pageY);  
  15.         })  
  16.     })  
  17. </script>  
  18.   
  19. </head>  
  20. <body>  
  21.     <form id="form1" runat="server">  
  22.     <div>  
  23.         <label id="lblMousePosition" style="background-color: Red;" />  
  24.     </div>  
  25.     </form>  
  26. </body>  
  27. </html>  
Now Run The Application:

x y axis
                                                                                    Image 1

Now move your mouse anywhere on screen.

mouse position
                                                                            Image 2

 

Ebook Download
View all
Learn
View all