Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 29th, 2004, 03:33 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom Cursors

I need to change the cursor that displayed when I hover over an image button. This is easy to do if you want to use one of the pre-defined cursors.

However, I need to change the cursor to use one of my own. I understand that this can be done in HTML/Javascript using the url() function. However, I need to do this from C# (i.e. from the server side) and need to be able to change it many times in response to certain events.

At the moment I am using the following to change to one of the pre-defined cursors:-
    imgButton.Style["CURSOR"] = "crosshair";

and I need to do the equivalent of:-
    imgButton.Style["CURSOR"] = "url('<myURL>')";

...only that doesn't work!

Does anyone know if this can be done?



 
Old May 29th, 2004, 06:19 AM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First of all: You can't change the cursor on the server. The cursor is rendered by the browser and the only way to change it is by changing the style (in a stylesheet or by javascript). Besides that: The cursor style property is not part of the CSS. Its only supported by IE and not by Netscape, Opera etc.
Finally, I can't think of a way to define your own cursor in IE. You have to use one of the cursors that Microsoft has provided.

Regards

Gerhard Wentink
 
Old May 29th, 2004, 07:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hmmm, I am afraid all of this isn't true.....

First of all, gp_mk *is* trying to change the cursor at the client, but through server-side code.

  imgButton.Style["CURSOR"] = "crosshair";

will add a style attribute to the image. That attribute ends up at the client. However, this will of course only take place after the page has loaded; not while the server is processing stuff.

Secondly, the cursor *is* a part of the W3 specs, CSS2: http://www.w3.org/TR/REC-CSS2/ui.html#propdef-cursor

Thirdly, most browsers understand the default stuff like crosshair, etc. I tested this on Opera, Firefox, Mozilla and Netscape and they all displayed crosshair for example with this code:

<p style="cursor:crosshair;">
Hello
</p>

or this code:

p
{
  cursor: crosshair;
}

However, support for the URL way of defining the cursor is not supported very well. From all browsers I tested, only IE seems to handle this well. I added code like this:

  Button1.Style["cursor"] = "url('/3dgnesw.cur'), crosshair";

and I ended up with the custom cursor (copied from Windows\Cursors to the root of my site) called 3dgnesw.cur.

On what browser did you test this? Is the cursor you are referring to available on your Web site? You can't use one of the cursors from the Cursors folder directly....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 29th, 2004, 09:28 AM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar is right as always. I bow my head



Gerhard Wentink
 
Old May 29th, 2004, 09:36 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar,

It turns out there was a problem with the URL I was passing in for the cursor file. The following line now works fine when the "cross.cur" file is in the root of my web site:-

   btnImage.Style["CURSOR"] = "url('cross.cur')";

It's good to know this can be done, as I haven't seen any documentation anywhere for doing this from server-side code

Cheers,
Gary

 
Old May 29th, 2004, 11:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, don't feel too bad about it. With the current inaccessibility of the W3C recommendations / documents, no one will blame you for not knowing about the cursor property ;)

If I am not mistaken, it used to be an IE only invention, and was later added to CSS level 2.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 29th, 2004, 12:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar; feeling a lot better now. I recently bought Eric Meyer's "CSS, The Definitive guide", only to find out that the second edition came out two weeks later. Bought this one too, but did not have the chance to read it, yet.

Regards,

Gerhard Wentink





Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Data from Oracle cursors k_kosaraju ADO.NET 2 January 27th, 2009 11:38 AM
Maximum number of cursors exceeded. zaheerabbas.sk Oracle 1 July 4th, 2008 04:41 AM
MYSQL and Cursors paulkholt MySQL 1 September 8th, 2004 08:25 AM
Changing cursors in onmouse??? events badgolfer ASP.NET 1.0 and 1.1 Basics 2 July 21st, 2004 08:49 AM
Custom Cursors gp_mk Classic ASP Basics 0 May 29th, 2004 03:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.