Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 3.75 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2006, 09:46 AM   PM User | #1
LiLo
New Coder

 
Join Date: Feb 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
LiLo is an unknown quantity at this point
Question Asp.net methods which find mouse coordinates?

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?
LiLo is offline   Reply With Quote
Old 03-21-2006, 03:29 AM   PM User | #2
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
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.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 03-22-2006, 12:57 PM   PM User | #3
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
Quote:
Originally Posted by LiLo
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


Code:
//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
handshakeit is offline   Reply With Quote
Old 03-22-2006, 01:20 PM   PM User | #4
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
The original poster was looking for a .NET function to determine cursor position. Your code doesn't appear to offer that.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 03-23-2006, 04:11 AM   PM User | #5
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
Yes you r right but for this he give the code him self and asked
the some other way to do this

Code:
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
handshakeit is offline   Reply With Quote
Old 03-23-2006, 04:20 AM   PM User | #6
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
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.
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 03-24-2006, 06:02 AM   PM User | #7
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
Hi Brandoe85

Presently the question was for window form

Quote:
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
handshakeit is offline   Reply With Quote
Old 03-27-2006, 05:34 AM   PM User | #8
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
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
handshakeit is offline   Reply With Quote
Old 03-27-2006, 06:07 AM   PM User | #9
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
I tried the following code working correctly

Code:
<script type="text/javascript" language="javascript">
    function over()
    {
    alert("hi");
    }
    function out()
    {
    alert("bye");
    }
    </script>
Code:
<input id="Button1" type="button"  onmouseover="over()" onmouseout="out()" value="button" />
hope this is what u want
thanx
Abhi
handshakeit is offline   Reply With Quote
Old 04-03-2006, 06:27 AM   PM User | #10
handshakeit
New Coder

 
Join Date: Oct 2005
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
handshakeit is an unknown quantity at this point
Hi LiLo

Is yor problem is solved???
__________________
warm Regards
Abhishek Goel
Software Developer at Handdshakeit (Handshake Infotech Pvt. Ltd)
--------------------------------------------------
ActiveX HTML Editor control
handshakeit is offline   Reply With Quote
Old 01-27-2009, 03:47 AM   PM User | #11
demtron
Regular Coder

 
Join Date: Jun 2008
Location: SE Wisconsin, US
Posts: 222
Thanks: 1
Thanked 20 Times in 20 Posts
demtron is on a distinguished road
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.
__________________
Milwaukee Web Designer and SEO Milwaukee Firm specializing in ASP.Net, C#, VB.Net, SQL Server and Access.
demtron is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:46 PM.


Advertisement
Log in to turn off these ads.