Below is my code:

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

x y axis
Image 1

Now move your mouse anywhere on screen.

mouse position
Image 2