How to pass the coordinates of the mouse double-click on the web application to the server side and operate it? I will introduce this question, I hope to help everyone.
The double-click event of the mouse is a client event, which cannot obtain the coordinates of the mouse double-click point directly on the server, and cannot be effectively operated. Therefore, the need must be achieved through the combination of client events and server-side events.
Step 1: Create a client control
At the client we can create an HTML control. In the program, you can create an HTMLINPUTHIDEN control if you do not want the mouse double click on the coordinate display on the page. The controls I created are as follows:
Protected system.Web.ui.htmlcontrols.htmlinputhidden hidx;
Protected system.web.ui.htmlcontrols.htmlinputhidden hid;
If you want to double-click the coordinate, you can create the appropriate client control according to your needs.
Step 2: Create server-side controls
For the sake of simplicity display procedure, I created two Label controls and a Button control. as follows:
protected system.web.ui.webcontrols.label lblx;
protected system.web.ui.webcontrols.label lbly;
Protected system.Web.ui.webcontrols.button btnxy;
Step 3: Add client code
In order to pass the coordinates of the mouse double-click to two HTML controls in the form: write scripts:
Function shubiao_ondblclick ()
{
Document.form1.hidx.value = window.event.clientX;
Document.form1.hidy.value = window.event.clienty;
}
script>
Add an onDblclick () event for Body
Step 4: Add server-side code
On the server-side Button control btnxy clicks, you can accept the coordinate value of the mouse double click:
Private void btnxy_click (Object Sender, System.Eventargs E)
{
LBLX.TEXT = "x coordinate:" hidx.value;
Lbly.text = "y coordinate:" Hidy.Value;
}
Through the above steps, we can pass the coordinates of the client's mouse to the server side. Next, these coordinate values can be used to implement our other needs.