简体   繁体   English

ASP.Net中的加载屏幕

[英]Loading screen in ASP.Net

I'm building a few webpages in my webapplication which use a webservice. 我正在使用Web服务的Web应用程序中构建一些网页。 While communicating with the webservice, which can take more than a few seconds, I want to display a loading screen. 与Web服务通信时(可能需要花费几秒钟的时间),我想显示一个加载屏幕。 Something like the jquery dialog, where the background is disabled and a loading image appears in the middel of the webpage. 类似于jquery对话框,其中禁用了背景,并且加载的图像出现在网页的中间。

Is this possible and how can I do this? 这可能吗,我该怎么做?

I use blockUI plugin for such requirement. 我使用blockUI插件来满足这种要求。 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 在ajax请求的成功和失败回调中,包括取消阻塞的调用

$.unblockUI();

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). 看一下jqModal jQuery插件-我广泛使用了该插件,例如,在使用Facebook执行单点登录时,我会显示一个漂亮的“与Facebook连接”对话框(背景为空白)。 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). 它基本上是页面上的一个隐藏的div(绝对位置),它被显示并居中(当然还有其他很酷的效果,例如淡入淡出)。

So you have full customization of this div - put an image, put an iframe, put a user control. 因此,您可以对该div进行完全自定义-放置图片,放置iframe和放置用户控件。

And it fully supports AJAX - so you can call your WS on load of this modal dialog to load the contents in. 它完全支持AJAX-因此您可以在此模式对话框加载时调用WS来加载内容。

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. 当然,您可以滚动自己的图像(老式的弹出窗口,或带有适当的z-index的叠加图像),但是重新发明轮子是没有意义的-尤其是当有很多出色的解决方案可用时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM