Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ASP.NET MVC provide any way to implement UpdateProgress WebForms control analog?

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?

like image 826
Freak Wild Cowhunter Avatar asked Dec 07 '25 18:12

Freak Wild Cowhunter


1 Answers

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 );
         }
      });
 });
like image 63
tvanfosson Avatar answered Dec 10 '25 10:12

tvanfosson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!