views:

39

answers:

2

Hi,

I'm building a few webpages in my webapplication which use a webservice. While communicating with the webservice, which can take more than a few seconds, I want to display a loading screen. Something like the jquery dialog, where the background is disabled and a loading image appears in the middel of the webpage.

Is this possible and how can I do this?

+1  A: 

I use blockUI plugin for such requirement. Its pretty simple and straight forward to use. For example:

$.blockUI({ message: '<h2>Loading</h2>' });
// call to the web service

And in success and failure callbacks of ajax request, include call to unblock

$.unblockUI();
VinayC
Thx for your answer. I get it to work, but only after Page_Load. I don't have a clue how to implement the blockUI before my Page_Load and how to do the unblockUI after Page_Load. I tried the Scriptmanager make a call to it: ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "openDialogScript", "$.blockUI({ message: '<h1><img src='busy.gif' /> Just a moment...</h1>' });", true);
Ben
The webservice is called in the page_load.
Ben
@Ben, how to do you call your web service? Are you using jquery ajax method or some thing else such as ScriptManager generated proxies?
VinayC
I found the problem! The scripts are executed after the Page_Load in Asp. So now I put the $.blockUI({ message: '<h2>Loading</h2>' }); in the onclick event of the link to my page with the webservice. So when I click the link to the page, my screen says loading and my page starts its Page_Load with the webservice. And in the script of my loaded page I put $.unblockUI();. I just use a webservice implemented with Visual Studio. Which I can use by makeing an object of that webservice.
Ben
+1  A: 

Take a look at the jqModal jQuery plugin - i use this extensively, for example when performing a single-sign-on with Facebook, i show a pretty "Connecting with Facebook" dialog (background is blanked out). very easy to use, and very extensible.

It's basically a hidden div on the page (absolute positioning), which gets shown and centered (and of course other cool effects, such as fading).

So you have full customization of this div - put an image, put an iframe, put a user control.

And it fully supports AJAX - so you can call your WS on load of this modal dialog to load the contents in.

Of course you could roll your own (old school popup, or overlayed image with appropriate z-index), but no point in re-inventing the wheel - especially when there are bucketloads of great solutions available.

RPM1984