views:

1069

answers:

2

Dear techies,

I have an ASP.NET 2.0 Web application.I want to show a progress indcator when user saves some data (Ex : Editing profile).I have already used jQuery in my application for some client side effects. How can i do this ? any jquery trusted stuff to use along with ASP.NET ? Thanks in advance

+1  A: 

Do you want to show actual progress or just a busy indicator while the action is happening? If the former, you'll need to have some mechanism to record the save progress in the session and a method to check the state of the progress via AJAX. You'd submit the form via AJAX then periodically call the check method to get reports of the progress and update whatever client-side indicator (usually switch from one to another of a series of canned images or increase the width of some filled "bar"). This, of course, is complicated.

If you want to do the latter, just display an animated GIF that's a busy indicator while you submit the form via AJAX from jQuery using the beforeSend callback, then hide the indicator using the ajax method's complete handler.

$('form').ajax( {
    url: '/updateprofile.aspx',
    type: 'POST',
    data: function() { return $('form').serialize(); },
    beforeSend: function() { $('#indicator').show(); },
    complete: function() { $('#indicator').hide(); },
    success: function(data,status) { alert('Update complete'); }
});

The above code would be in the function invoked from whatever handler invokes the submission or hooked to the form's submit event -- though you'd have to prevent the default action from taking place, too.

tvanfosson
I Am not using an ajax form post. I do save the data in the server side even of a asp.net button click.I never used ajax form submit.Is there not a risk factor in using that method ? I m not sure about it .Whats the advantage of using ajax for posting ?
Shyju
@tvanofosson this answer saved my day...
Pandiya Chendur
A: 

An alternative to showing a meaningful progress indicator is to show an animated gif whilst the data is being saved, e.g. the spinning 'daisy' pattern used in Firefox.

This shows the user that something is happening and is usually well received.

Progress indicators which show % complete are often meaningless anyway unless they really have an idea how long the first '50%' will take compared to the last '50%'. Other progress indicators are more meaningful, e.g. those showing record count increments, etc.

AdamRalph
Not necessarily the case because the animation will continue even if the server blows up whilst updating.
Ian Roke
True, not suitable in all cases, but often is enough. I'd go with a proper indicator which talks to the server given enough time to implement.
AdamRalph