在访问服务器期间显示 .gif 并继续播放 - asp .net

发布于 2024-12-20 08:04:17 字数 237 浏览 4 评论 0原文

我有一个按钮,已连接了 clientClick 事件处理程序和 Click(服务器)事件处理程序。在 clientClick 上,我想显示一个动画 gif,并且我希望它在访问服务器期间继续播放。目前,gif 会短暂显示,然后其动画“暂停”,然后重新加载页面。我希望 gif 一直播放到页面重新加载。

正如您可能猜到的那样 - 这样做的全部目的是实现“鸡蛋计时器”功能,以便用户了解正在发生的事情。

非常感谢,

I have a button of which I have wired up a clientClick event handler and Click (server) event handler. On clientClick I would like to display an animated gif, and I'd like this to continue playing during the trip to the server. At the moment, gif is displayed momentarily, then it's animation is 'paused' and then page reloaded. I'd like the gif to play right up until the page is reloaded.

As you can probably guess - the whole point of this is to implement an 'egg-timer' feature for the users to be aware of the fact that something's going on.

Thanks a lot,

Dan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

未央 2024-12-27 08:04:17

您必须使用更新面板,并从服务器端注册此 document.all["slowScreenSplash"].style.display = "none"; 代码。

我已经说明了如果您使用更新面板,如何从服务器端注册 JS 的语法。

这比进度条示例更好。


正在处理您的请求,请稍候...

在按钮 clientclick 事件上调用此事件。

    document.all["slowScreenSplash"].style.display = "none";

string scriptstring = "alert('Welcome');";  
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", scriptstring, true);  

You have to use Update Panel and from Server side you have to register this document.all["slowScreenSplash"].style.display = "none"; code.

I have illustrate the the syntax how to register JS from server side if you are using the update panel.

This is batter than the progressbar example.

<DIV ID="slowScreenSplash" STYLE="position:absolute;z-index:5;top:40%;left:15%;"
align="center">

Please wait whilst your request is being processed...
</DIV>

call this event on button clientclick event.

    document.all["slowScreenSplash"].style.display = "none";

string scriptstring = "alert('Welcome');";  
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", scriptstring, true);  
怀中猫帐中妖 2024-12-27 08:04:17

由于您正在开发 asp.net,我猜测您没有实现大量 JavaScript 或 Ajax。

有用于 ASP.NET 的 AJAX 插件,您可以使用刷新容器(不能 100% 确定它是否被称为这个容器),然后连接到其中的事件。

这可能是最简单的方法。您还可以阅读 jQuery,它们提供了非常易于使用的 AJAX 方法。当然,您必须在服务器上提供一个方法来进行处理并返回响应。然后,一旦收到响应(可以通过 jQuery AJAX 方法轻松访问此方法),请将内容插入页面并关闭动画。

如果这听起来很多,只需在 ASP.NET 中使用 AJAX(查找 AJAX Control Toolkit)即可。

Since you are doing asp.net I am guessing youre not implementing a whole lot of JavaScript or Ajax.

There are AJAX plugins for ASP.NET and you could use the refresh container (not 100% sure if that's what it's called) and just hook up to the events in that.

That would probably be the easiest method. You could also read up on jQuery, they provide an AJAX method that is really easy to use. Of course, you will have to provide a method on the server that does the processing and returns the response. Then once you get the response (method for this is easily accessed from the jQuery AJAX method) insert the content into the page and turn the animation off.

If that sounds like a lot just go AJAX in ASP.NET (lookup AJAX Control Toolkit).

夜未央樱花落 2024-12-27 08:04:17

我将其分成三个文件 - 您的初始表单 - 一个用于处理缓慢任务的页面 - 一个用于呈现任务输出的页面。

将动画 gif 放在第二页的顶部,使用 Response.Flush 将一些 html 推送回浏览器(这将渲染并播放 gif)。当您完成处理 Resoponse.Write 一个 javascript 片段以将浏览器重定向到该过程中的最终页面。

I'd split it in to three files - your initial form - a page to process the slow task - a page to render the output of the task.

Put the animated gif at the top of the second page, use Response.Flush to push some html back to the browser (this will render and play the gif). When your finished processing Resoponse.Write a javascript fragment to re-direct the browser to the final page in the process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文