c#  javascript busybox

Posted on 2007-08-04
Last Modified: 2013-11-07
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
Question by:B_P_B
    LVL 4

    Accepted Solution

    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.


    Author Comment

    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?
    LVL 4

    Assisted Solution

    by:Tommie Nathaniel Carter, Jr., MBA
    Try putting the Process Stuff function call into the LoadComplete event per this article.
    LVL 1

    Expert Comment

    There is a thing called jquery, 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

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Suggested Solutions

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now