You need to handle the onmousemove and onclick event of your panel in
JavaScript.
I've attached an example in C# (should be easy to convert to VB.net).
the getPanelMouseCoOrds JavasScript sets two text boxes (so you can see
it in action) and two hidden fields with the mouse postion.
The onclick handler just submits the form.
When the form is posted back to server the PageLoad extracts the values
from the two hidden form fields and sets the label for info
It works in IE but may ntyo work in other browsers:
Webform1.aspx:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="PanelMousePosition.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT id="hidX" name="hidX" type="hidden"> <INPUT id="hidY"
name="hidY" type="hidden">
<asp

anel id="Panel1" runat="server" Width="423px" Height="94px"
BorderStyle="Solid">Panel</asp

anel>
<p>X: <input name="xPos" type="text" size="5"></p>
<p>Y: <input name="yPos" type="text" size="5"></p>
<asp:Label id="Label1" runat="server"></asp:Label>
<script language="JavaScript">
function getPanelMouseCoOrds()
{
var mouseX = event.clientX + document.body.scrollLeft;
var mouseY = event.clientY + document.body.scrollTop;
document.Form1.xPos.value = mouseX;
document.Form1.yPos.value = mouseY;
document.Form1.hidX.value = mouseX;
document.Form1.hidY.value = mouseY;
return true;
}
function handlePanelClick()
{
document.Form1.submit();
}
</script>
</form>
</body>
</HTML>
and there's the code behind to register and handle events
(WebForm1.aspx.cs):
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace PanelMousePosition
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Panel Panel1;
private void Page_Load(object sender, System.EventArgs e)
{
if (! Page.IsPostBack)
{
Panel1.Attributes["onmousemove"]="getPanelMouseCoOrds()";
Panel1.Attributes["onclick"]="handlePanelClick()";
}
else
{
int panelX = Int32.Parse(Request.Form["hidX"]);
int panelY = Int32.Parse(Request.Form["hidY"]);
Label1.Text = "You clicked @ " + panelX + ", " + panelY;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}