• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1196
  • Last Modified:

c# javascript busybox

I am trying to implement a simple please wait box. The box is a DIV with an gif running in it. The Div is by default hidden.

<div ID="PleaseWait" runat="server"   Style="background-attachment: fixed;
    left: 49px; background-image: url(images/gear.gif); background-repeat: no-repeat;
    position: absolute; top: 377px; border-top-style: ridge; border-right-style: ridge; border-left-style: ridge; border-bottom-style: ridge; width: 206px; height: 161px; z-index: 1000; visibility: hidden;"  >
    <asp:Label ID="Label9" runat="server" Style="left: 3px; position: absolute; top: 143px;
        text-align: center" Text="zPlease Wait...." Width="205px"></asp:Label>

all I do is change the visibility style from hidden to visible with a javascript function

function ShowPleaseWait()
 document.getElementById("PleaseWait").style.visibility= "visible";

I invoke this from my C# file by:

 public void test1()

                       string script = "<script type=\"text/javascript\">"+
                            "ShowPleaseWait(); "+

            Page page = HttpContext.Current.CurrentHandler as Page;

            if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("busybox"))
                page.ClientScript.RegisterClientScriptBlock(typeof(JavaScriptUtilities), "busybox", script);

all works well...until I have a busy serverside routine following the call to test1()... then the gif box doesn't show until after the busy serverside routine has finished.

What am I doing wrong??? is there a way I can force the gif box to display before I start the busy serverside routine?

I tried windows.timeout - but no luck there

Please help
  • 2
2 Solutions
Tommie Nathaniel Carter, Jr., MBAFounderCommented:
No doing anything wrong. If a server operation is preventing the page from fully loading (which it is in this case) then the javascript cannot load/run properly on the client machine. Find a way to either minimize the server operations or move the javascript higher in the load sequence of the page (possibly making it an inline function) and test for effect.

B_P_BAuthor Commented:
I have the function ShowPleaseWait() embedded in the html code is that what is meant by inline. The server is requesting information from another server and it can take up to 20 seconds to recieve a response back.

in my c# codebehind file I have :

protected void ProcessStuff()
test1();  //turn on the busybox
getinformation(); // get the information from remote server...can take up to 20seconds

is there a way to allow the client page to fully render before calling the getinformation procedure?
Tommie Nathaniel Carter, Jr., MBAFounderCommented:
Try putting the Process Stuff function call into the LoadComplete event per this article.

There is a thing called jquery, www.jquery.com and there is a plugin for that called blockUI. This plugin blocks the whole UI and you can't click anywhere while it's up. It's all free and opensource etc. so copyright won't be a problem. Say if you were calling the heavy serverload with a link you could do like <a href="somehref" onclick="javascript:$(document).blockUI('$("hiddenDiv")')" > or something like that, really easy to learn, really easy to code.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now