Updatepanels:防止同一用户发出多个并发请求?

发布于 2024-08-07 07:33:58 字数 419 浏览 3 评论 0原文

在一个相当复杂的带有大更新面板的屏幕上,我遇到了以下问题:

如果用户非常快地单击某个按钮 6 或 7 次,则似乎最终会不按顺序处理最后一个请求,从而出现问题。具体来说,有一个 xml 文档处于会话状态,并且它不同步。

我真正想做的是阻止点击此按钮,直到回发完成。我知道我可能会找到一种简单的方法来使用 Javascript 来做到这一点,但它似乎可能是内置的。

有什么想法吗?

注意:下面的答案很有帮助,但没有解决问题。使用 onClientClick 禁用链接按钮并在再次启用回发后允许其返回后,问题仍然存在。尽管更新面板已经在屏幕上绘制了新的、启用的链接按钮,但几乎就好像更新面板还没有完成所有操作。

更多注释(已解决!):我通过使用 BlockUI(jQuery 插件)解决了这个问题。请参阅下面我的回答。

On a rather complicated screen with a big updatepanel, I'm running into the following problem:

If a user clicks on a certain button 6 or 7 times really fast, it seems to eventually process the last request out of turn and problems occur. Specifically, there's an xml document in session state, and it gets out of sync.

What I really want to do is block clicks to this button until the postback completes. I know I could probably find an easy way to do this with Javascript, but it seems like it might be built-in.

Any thoughts?

Note: The answers below are helpful, but they haven't solved the problem. After disabling the linkbutton with onClientClick and then allowing it to come back after the postback enabled again, the problem persists. It's almost as if the updatepanel isn't quite done with everything even though it has drawn the fresh, enabled linkbutton on the screen.

More notes (solved!): I solved this one by using BlockUI (jQuery plugin). See my answer below.

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

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

发布评论

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

评论(5

無處可尋 2024-08-14 07:33:58

ASP.NET UpdatePanel 始终尊重最后一个请求。如果您在处理请求时发出请求,第一个请求将被终止并处理当前请求。它的设计和构建就是为了以这种方式工作。

单击按钮后,我将使用 JavaScript 禁用该按钮。

ASP.NET UpdatePanel always honors the last request. If you make a request while one is processing, the first requests gets terminated and the current one is processed. It was designed and built to work this way.

I would disable the button with JavaScript once it has been clicked.

王权女流氓 2024-08-14 07:33:58

更新面板?我假设您正在使用 MS AJAX,如果是这样,我建议您下载 AJAX 工具包(如果您还没有这样做的话)。该工具包附带了许多现成的控件和扩展,可帮助您开发支持 AJAX 的应用程序。例如,有一个名为“ConfirmButton”的扩展,可以帮助您防止用户多次单击按钮,而且它还以一种非常酷和优雅的方式做到这一点。

另一种选择是使用 JavaScript 或更好的方法,创建一个自定义按钮控件,该控件具有单击后禁用的属性,如果这样做,则可以很容易地在其他应用程序中重用它。

希望这有帮助。

UpdatePanel? I will assume you are using MS AJAX, if so I will recommend you download the AJAX toolkit if you have not done so. This toolkit comes with many ready to use controls, and extensions to help you in your AJAX enabled app. For example, there is one extension called "ConfirmButton" that will help you prevent the user from clicking in a button more than once, and it also does it in a very cool and elegant manner.

Another option will be to use JavaScript or better yet, create a custom button control that has a property to be disabled after it is clicked, if you do that, it will be really easy to reuse it in your other applications.

Hope this helps.

兲鉂ぱ嘚淚 2024-08-14 07:33:58

在我不久前开发的一个自制 AJAX 框架中,我们只是记录了 javascript 中的最后一次调用(带有许多参数的 javascript 函数调用),并阻止了具有相同参数的后续调用。这并不理想,但在紧要关头却起到了作用。

In a home-rolled AJAX framework I worked on awhile back, we simply logged the last call in javascript (javascript function call with many parameters) and prevented subsequent calls with identical parameters. It wasn't ideal, but it did the trick in a pinch.

染年凉城似染瑾 2024-08-14 07:33:58

我在基础设施控制方面遇到了一些“异步”问题,但在 Scripmanager 中添加 ScriptMode="Release" 后,问题得到了解决。

I was having some "Asyc" problems with infragistics control, but after adding ScriptMode="Release" in Scripmanager the problem was resolve.

随遇而安 2024-08-14 07:33:58

下面的链接在大约半小时内解决了我的问题。由于 updatepanel 的时间安排,仅使用 javascript 禁用(我尝试了几种不同的方法...)并没有达到目的。

在异步回发时禁用 UpdatePanel进行中

The link below solved my problem in about half an hour. Just going with a javascript disable (and I tried several different ways...) did not do the trick due to the timing of the updatepanel.

Disabling UpdatePanels While an Asynchronous Postback is in Progress

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