Need Mechanism or code for wait state in asp.net web application

  • Thread starter Thread starter SP
  • Start date Start date
S

SP

Hi,
I want to add wait cursor code whenever page is post back. Page may be
post back on my user control's or on change of dropdown or on click of any
button on page. so is there any common solution available that will provide
me mechanism to display wait cursor or wait image to user whenever page is
post back to server?

Thanks,


--
 
put a script on body on event onbeforeunload="ChangeCursorStatus();"

javascript:
function ChangeCursorStatus(){
document.body.style.cursor = "wait";
}

it's very unpleasant this solution because you have to put in every page,
but it works. I couldn't find any other solution to put this code dinamically
on body :(.

Cheers
 
Thanks Psycho,

I tried that solution but it will solve my half problem, actually i want
to display user a cursor and also put application in wait state that user
can not perform another action till one action is performed. means if user
click on my save button then till save action is performed and page is load
till that user can not perform any other action means he will restrict till
one action performed.

I have one solution of threading. means put application in thread and wait
that thread for some second and till that display some image after
completing this i show form to user. but it will give error when i redirect
page to another page that data can not send because of http header is
already written.

If you will know any other solution than please tell me.

Thanks once again,
 
you should try to make all of your controls disabled. i use a javascript also
for this task. So on event onbeforeunload put another javascript to disable
controls or make a function which is doing your both tasks.

some function like this
function DisableControls(){
nr = document.forms[0].all.length;
for(i=0;i<nr;i++){
if(document.forms[0].all(i).tagName == "SELECT" ||
(document.forms[0].all(i).tagName == "INPUT" &&
(document.forms[0].all(i).type == "radio" || document.forms[0].all(i).type ==
"checkbox" || document.forms[0].all(i).type == "button") ))
document.forms[0].all(i).disabled = true;
}
}

Cheers
 
Hi SP:

You don't want to go anywhere near the threading classes for this one,
trust me. You need to perform actions on the client, and the least
intrusive way to do this is with client side script.

Psycho: If you create a base class to derive all your web forms from,
you can put a call to RegisterClientScript in one place and have the
script appear in all of your web forms. There are a few articles
around describing how inherit from the Page class to add useful
features. Here is one:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/BedrockASPNET.asp

HTH,
 
Thanks for advice Scott but i'm already using a customPage and also the
method RegisterStartupScript. My problem is with body. I can't attach any
event dinamically. I don't want to go to every page to put on body
runat="server" and id="body" just to add from behinde code, javascript on
body events. So I prefer to add on body events. Is any other way to do this?


Scott Allen said:
Hi SP:

You don't want to go anywhere near the threading classes for this one,
trust me. You need to perform actions on the client, and the least
intrusive way to do this is with client side script.

Psycho: If you create a base class to derive all your web forms from,
you can put a call to RegisterClientScript in one place and have the
script appear in all of your web forms. There are a few articles
around describing how inherit from the Page class to add useful
features. Here is one:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/BedrockASPNET.asp

HTH,
 
Ah, apologies - I didn't really think about the body tag needing to be
runat=server (and honestly, JavaScript is a real weak area for me).
 
Back
Top