Background
The stuck cursor problem only affects VS 2003, it is fixed in Visual Studio versions 2005 and above.
But in Visual Studio 2003 after deployment the cursor remains the default pointer for any and all
operations between all webpages of the application. This produces the effect where the user does not know if a page is executing or not if there is a lapse in time during a long running operation. Not only does this make the newly deployed application seem 'weak', it breaks a windows standard which has become part of all Microsoft Products. We can add back this functionality using Javascript and a little common sense.
Solution Framework
Two Javascript functions are constructed which will iterate through all the objects on the body of the form and set the cursor type as well as the body of the form.
!--
function wait_cursor() {
// insure all form objects have an id
document.body.style.cursor = 'wait';
var elem = document.getElementById('frm').elements;
for(var i = 0; i elem.length; i++)
{
elem[i].style.cursor="wait";
}
}
function default_cursor() {
// insure all form objects have an id
document.body.style.cursor = 'default';
var elem = document.getElementById('frm').elements;
for(var i = 0; i elem.length; i++)
{
elem[i].style.cursor="default";
}
}
// --
Solution
!--
function goNavNoReturn(l) {
wait_cursor();
//document.write(l);
location.replace(l);
}
function goNavAndReturn(l) {
wait_cursor();
//document.write(l);
window.open(l,'myWindow','location=0,menubar=0,status=0,toolbar=0,scrollbars=1,directories=0,resizable=1,width=100,height=100');
default_cursor();
}
// --
Cautions
This method will work only if the web page form has an ID attribute and all page objects located on the form also have
an ID attribute provided. Make sure all page objects have an ID. In years past before the specifications were somewhat uniformly read across applications it was a shortcut to simply give page objects a NAME attribute without defining an ID.
Now all objects must have both to insure they work across all applications. The makers of some applications may require only one or the other but in order to write code that flows across all applications built by all companies it is safer to just include both attributes now. This method works well in conjunction with Javascript Window Objects.
In Closing
On any function that will leave the page, include the wait_cursor() function call at the beginning of the operation. On any function that will leave the page and then return to the page, use both the wait_cursor() function call at the beginning of the operation and the default_cursor() function call at the end of the operation. That will reset the cursor back to its original state. This change must be propogated across all webpages in the application. The sourcecode in this article is available as a free download
Join the Conversation