Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,096
    Thanks
    2
    Thanked 23 Times in 23 Posts
    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!

  • #3
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,096
    Thanks
    2
    Thanked 23 Times in 23 Posts
    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!

  • #5
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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.

  • #7
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #9
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #10
    New Coder
    Join Date
    Oct 2005
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi LiLo

    Is yor problem is solved???
    warm Regards
    Abhishek Goel
    Software Developer at Handdshakeit (Handshake Infotech Pvt. Ltd)
    --------------------------------------------------
    ActiveX HTML Editor control

  • #11
    Regular Coder
    Join Date
    Jun 2008
    Location
    SE Wisconsin, US
    Posts
    222
    Thanks
    1
    Thanked 20 Times in 20 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •