“请稍候” 使用 ASP.NET 3.5 在每个用户操作上显示图像
在我们的 ASP.NET 3.5 应用程序中,我们希望实现“请稍候..”功能: 对于每个用户操作(按钮单击、选项卡更改等),我们都会在页面顶部显示一个小微调器(实际上在我们已经使用的单独框架中)。
我们想到了这个解决方案:
- “劫持”
_doPostBack
来拦截每个事件,显示旋转图像,然后执行原始的_doPostBack
函数 - 在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 :
- "hijack" the
_doPostBack
to intercept every event, display the spinner image, then execute the original_doPostBack
function - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您已经在使用 UpdatePanels,因此只需添加 UpdateProgress控件到页面并将其关联到您的 UpdatePanel。
当从 UpdatePanel 内部启动部分回发时,它将自动显示,并在请求完成后隐藏。
下面是一个示例,只需将 img 标签指向旋转图像即可。 您可以将控件放置在您希望其出现的位置。
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.
我确信您可以将进度指示器附加到 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