“请稍候” 使用 ASP.NET 3.5 在每个用户操作上显示图像

发布于 2024-07-21 23:11:07 字数 402 浏览 0 评论 0原文

在我们的 ASP.NET 3.5 应用程序中,我们希望实现“请稍候..”功能: 对于每个用户操作(按钮单击、选项卡更改等),我们都会在页面顶部显示一个小微调器(实际上在我们已经使用的单独框架中)。

我们想到了这个解决方案:

  1. “劫持”_doPostBack来拦截每个事件,显示旋转图像,然后执行原始的_doPostBack函数
  2. 在ASP中注册一个客户端脚本块。 NET 代码隐藏在处理结束时隐藏图像

我的问题是:您认为这是一个好的解决方案吗? 它当然不是很优雅,但看起来相当有效。 是否有另一种解决方案/模式来做这种事情?

PS:我们不使用 JQuery,而是使用 UpdatePanels

In our ASP.NET 3.5 application, we would like to implement a "Please wait.." feature :
on every user action (button click, tab change, etc.) we would display a little spinner on top of the page (actually in a separate frame that we use already have).

We thought of this solution :

  1. "hijack" the _doPostBack to intercept every event, display the spinner image, then execute the original _doPostBack function
  2. register a client script block in the ASP.NET codebehind to hide the image when the processing ends

My question is : do you think it's a good solution ? it's certainly not very elegant but it seems quite efficient. Is there another solution/pattern to do this kind of thing ?

PS : we do not use JQuery and we use UpdatePanels

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

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

发布评论

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

评论(2

苏别ゝ 2024-07-28 23:11:07

由于您已经在使用 UpdatePanels,因此只需添加 UpdateProgress控件到页面并将其关联到您的 UpdatePanel。

当从 UpdatePanel 内部启动部分回发时,它将自动显示,并在请求完成后隐藏。

下面是一个示例,只需将 img 标签指向旋转图像即可。 您可以将控件放置在您希望其出现的位置。

<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="updatePanel1">
  <ProgressTemplate>
    <img src="./images/somespinner.gif" />Please wait...
  </ProgressTemplate>
</asp:UpdateProgress>

Since you are already using UpdatePanels, you just need to add an UpdateProgress control to the page and associate it to your UpdatePanel.

This will automatically show up when a partial postback is initiated from inside the UpdatePanel and hide once the request is completed.

Below is an example, just point the img tag to a spinner image. You can position the control where you want it to appear.

<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="updatePanel1">
  <ProgressTemplate>
    <img src="./images/somespinner.gif" />Please wait...
  </ProgressTemplate>
</asp:UpdateProgress>
相思碎 2024-07-28 23:11:07

我确信您可以将进度指示器附加到 UpdatePanel。 无论是通过事件处理程序还是通过属性,我不记得是哪一个了,已经有一段时间了,我使用 jQuery 而不是 UpdatePanels。

富有的

I'm sure you can attach progress indicators to the UpdatePanel. Either by event handler or by property, I can't remember which, it's been a while, I use jQuery not UpdatePanels.

Rich

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