ASP.NET MVC 是否提供任何方法来实现 UpdateProgress WebForms 控件模拟?

发布于 2024-07-27 20:18:03 字数 87 浏览 2 评论 0原文

ASP.NET MVC 是否提供任何方法来实现 UpdateProgress WebForms 控件模拟? 谁能解释一下如何使用 MVC 实现此类客户端功能?

Does ASP.NET MVC provide any way to implement UpdateProgress WebForms control analog? Can anyone explain me how to achieve such client-side functionality with MVC?

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

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

发布评论

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

评论(1

乱了心跳 2024-08-03 20:18:03

使用一点 jQuery 和 AJAX 可以很容易(或者复杂,如果你想做一些困难的事情)来做到这一点。 这个小片段通过将部分视图呈现为 HTML 的方法更新了 DIV。 它首先用加载消息替换当前内容,然后在返回数据时覆盖加载消息,用服务器的响应更新 DIV。 您可以执行其他操作,例如显示动画 GIF,或者变得非常复杂并设置间隔计时器来定期检查长时间运行的活动的状态并执行进度表。 显然,后者要复杂得多。

 $('#myButton').click( function() {
      $('#myDiv').html('Please wait while the data is loaded.');
      $.ajax({
         url: '<%= Url.Action( "action" ) %>',
         data: $('form').serialize(),
         type: 'post',
         dataType: 'html',
         success: function(data,status) {
             $('#myDiv').html( data );
         }
      });
 });

Using a little jQuery and AJAX makes it pretty easy (or complex, if you want to do something hard) to do this. This little snippet updates a DIV from a method that renders a partial view to HTML. It first replaces the current contents with a loading message, then updates the DIV with the response from the server by overwriting the loading message when the data is returned. You can do other things like showing an animated GIF or get really complex and set up an interval timer to periodically check the status of a long running activity and do a progress meter. Obviously, the latter is much more complex.

 $('#myButton').click( function() {
      $('#myDiv').html('Please wait while the data is loaded.');
      $.ajax({
         url: '<%= Url.Action( "action" ) %>',
         data: $('form').serialize(),
         type: 'post',
         dataType: 'html',
         success: function(data,status) {
             $('#myDiv').html( data );
         }
      });
 });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文