ajax.net progress bar with text box feedback

Posted by craig Monday, March 28, 2011 3:05:00 AM

There are many asp.net progress bars out there which are much prettier than this, but what I wanted was a generic solution to the problem where I have a long running operation in the background and I want to display a progress bar AND a running text info box, which can be updated as the background server side operation progresses.

Download Source : ajax_progressbar_with_text_feedback.zip 

 Ajax async execute with Progress bar and dynamic feedback text

Rather than make a control, I have a generic page to do the trick.    Since I can use the same page for all my large executions,  there is no real advantage to having a control, unless of course we want to reuse the control in another site.  Although even in this case, I can just copy the generic page.  I find this approach more flexible then the control.  Most of the logic is in the base class, which can be stored in a reusable common DLL.  Of course for high traffic sites, we need to be careful about abusing the session,  but for 99.9% of websites this is not an issue.  It is also unlikely that many users are simultaneously performing an expensive operation requiring AJAX.

The idea is to inherit from the base class  AsyncExecuteBase and override the Execute method. 

public virtual void Execute() {
Feedback.AddFeedbackLine("Starting Processing, sleeping 3s ", 0);
Thread.Sleep(3000);
// ... update the information text and percent complete as we go
Feedback.AddFeedbackLine("completed step 1 of 3, sleeping 3s ", 20);
Thread.Sleep(3000);
Feedback.IsComplete= true;
}

Before calling the page, the class is stored in the session variable.  When the button execute is called, we retreive the instance

var action = (AsyncExecuteBase) Session["ExecMethod" ];

The code is straightforward and simple the only other subtle point is that when reading and writing the Feedback I use a lock, to avoid partially updated strings.

 

Also note that normally the session variable would be set on another page, with the class implementing AsyncExecuteBase and then the user is redirected to the execution page, so the following code is only for the demo.

Session["ExecMethod"] = new AsyncExecuteBase(); // In practice this is set on another page which then redirects to this page for execution.

In a case where we want the text box with running information, we probably don't mind redirecting the user to another page.  Also note that the feedback is html so on completion we can add a link for the user to click.  In my applications this page inherits from the master page which provides the menus, headers and footers.

The progress bar  is the simplest possible.  It uses pure html and is 2 cell table. where the increasing width of the cell gives the progress information.  A much more esthetic progress bar is available here, but it does not have the possibility to update text.  at some point in the future, I might combine the two.  Let me know if you implement this before me!:

http://mattberseth.com/blog/2008/05/aspnet_ajax_progress_bar_contr.html

 

Copyright 2009 AnyTime

re: ajax.net progress bar with text box feedback

Sunday, May 06, 2012 11:41:28 PM ramos w17 pro

ramos w17 pro android 2.2 tablet pc is the cheapest tablet pc this month; it costs about $85 including the shipping fee. It is much cheaper than the last cheapest one ramos w17 pro. ramos w17 pro comes with the real android 2.2 OS supporting flash, 7 inch touch screen. Even though it is so cheap, the CPU of it is WM8650, High-performance 800MHZ CPU+300MHZ DSP, people will have a better experience with it; BTW, it doesn't support GPS function.

re: ajax.net progress bar with text box feedback

Tuesday, December 20, 2011 10:31:52 AM craig

Sorry for the late reply, the link was missing the start... here is the correct link:

 

http://www.any-ti.me/Data/Sites/5/blogdata/ajax_progressbar_with_text_feedback.zip
 

re: ajax.net progress bar with text box feedback

Tuesday, December 20, 2011 10:30:08 AM craig

Sorry for the late reply, the link was missing the start... here is the correct link:

 

http://www.any-ti.me/Data/Sites/5/blogdata/ajax_progressbar_with_text_feedback.zip

re: ajax.net progress bar with text box feedback

Wednesday, July 06, 2011 7:53:50 AM Olli

Hy,

i can't download this great tutorial ...

Can you fix the file/link ?

Thanks

Regards