...

View Full Version : Asp.net methods which find mouse coordinates?



LiLo
03-20-2006, 10:46 AM
Hi,

Are there asp.net functions to find the cursor position of a mouse?
Also, are there asp.net functions to find if the mouse cursor is within a listbox?

A C# (windows forms) code sample is shown below:

Listbox lb; //lb is a listbox
Point cpos = lb.PointToClient(Cursor.Position); //find coordinates of mouse
if(lb.ClientRectangle.Contains(cpos)) //if mouse cursor is within the listbox

Are there any asp.net functions which can do the same as the above c# methods?

vinyl-junkie
03-21-2006, 04:29 AM
I searched the MSDN library and didn't see anything other than what you posted. That seems to be the only way to do it.

handshakeit
03-22-2006, 01:57 PM
Hi,

Are there asp.net functions to find the cursor position of a mouse?
Also, are there asp.net functions to find if the mouse cursor is within a listbox?

A C# (windows forms) code sample is shown below:

Listbox lb; //lb is a listbox
Point cpos = lb.PointToClient(Cursor.Position); //find coordinates of mouse
if(lb.ClientRectangle.Contains(cpos)) //if mouse cursor is within the listbox

Are there any asp.net functions which can do the same as the above c# methods?

Yes you can do this by adding an event handler with the list box control
there is an events with listbox control
MouseEnter and MouseLeave
then assign deligate functions to these handlers
define delegete functions whan ever you want to do with these events




//add handlers
this.listBox1.MouseEnter+=new EventHandler(listBox1_MouseEnter);
this.listBox1.MouseLeave+=new EventHandler(listBox1_MouseLeave);


//define delegete functions
private void listBox1_MouseEnter(object sender, System.EventArgs e)
{
MessageBox.Show("I am in listbox");
}
private void listBox1_MouseLeave(object sender, System.EventArgs e)
{
MessageBox.Show("I am out of listbox");
}



Hope this will help you
Thanks
Abhi
Handshakeit (http://www.handshakeit.com)

vinyl-junkie
03-22-2006, 02:20 PM
The original poster was looking for a .NET function to determine cursor position. Your code doesn't appear to offer that.

handshakeit
03-23-2006, 05:11 AM
Yes you r right but for this he give the code him self and asked
the some other way to do this




Point cpos = lb.PointToClient(Cursor.Position); //find coordinates of mouse
if(lb.ClientRectangle.Contains(cpos)) //if mouse cursor is within the listbox



I think the code i give also do the same with a function........

Thanks
Abhi
Handshakeit (http://www.handshakeit.com)

Brandoe85
03-23-2006, 05:20 AM
When in fact you'd have to detect these things with javascript.

1. These events don't exists for the asp.net list box.
2. MessageBox.Show() doesn't exists in asp.net

Remember, windows forms applications are not the same as asp.net web applications even though they are written in the same language.

handshakeit
03-24-2006, 07:02 AM
Hi Brandoe85

Presently the question was for window form


A C# (windows forms) code sample is shown below:

Listbox lb; //lb is a listbox
Point cpos = lb.PointToClient(Cursor.Position); //find coordinates of mousehttp://www.codingforums.com/editpost.php?do=editpost&p=425629
Edit/Delete Message
if(lb.ClientRectangle.Contains(cpos)) //if mouse cursor is within the listbox

Are there any asp.net functions which can do the same as the above c# methods?

Presently i am working in C# only
I have little knowledge of ASP.Net using C#
I want to Know can I capture Mouse position in ASP.Net as we does in window application???

Thanx
Abhi
Handshakeit (http://www.handshakeit.com)

handshakeit
03-27-2006, 06:34 AM
Perhaps there is a solution if u use html controls instead of webcontrols like this
<label id="label1" runat="server" onmouseover="over()" onmouseout="out()"></label>
then define java script functions over() and out()

Try out
it could work
Thanx
Abhi
Handshakeit (http://www.handshakeit.com)

handshakeit
03-27-2006, 07:07 AM
I tried the following code working correctly


<script type="text/javascript" language="javascript">
function over()
{
alert("hi");
}
function out()
{
alert("bye");
}
</script>



<input id="Button1" type="button" onmouseover="over()" onmouseout="out()" value="button" />

hope this is what u want
thanx
Abhi

handshakeit
04-03-2006, 07:27 AM
Hi LiLo

Is yor problem is solved???

demtron
01-27-2009, 04:47 AM
For anyone who is still interested, the only way to capture mouse position within a browser is by using JavaScript. This could be passed via a web service or Ajax call back to the server, at this point it could be used by ASP.Net. But, nothing in an HTTP request automatically sends cursor coordinates.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum