Updating Progress Bar Value from server side Callback function

5 posts, 0 answers
  1. Felix
    Felix avatar
    7 posts
    Member since:
    Nov 2012

    Posted 10 Feb 2015 Link to this post

    Hello,

    We are trying to update a Progress bar from a Callback function that returns progress on a printing job from a code behind function.

    The code behind method is as follows:

      private  void ClientOnJobProgress(object sender, JobProgressEventArgs arguments)
            {
                Console.WriteLine("Progress: {0:000}% with job state {1}", arguments.Progress, arguments.State.ToString());
                Progress = arguments.Progress;
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "progress", "AdjustProgressBar('" + arguments.Progress + "');", true);

               //  RadProgressBar1.Value = arguments.Progress;       
            }
    If I set the Progress Bar Value as in the comments line above , the progress is only updated when the job is 100% complete and does not update during the process.  I tried calling a JavaScript function from the codebehind that finds the progress bar element in the document and tries to update the progress bar value then. Which doesnt update at all.

      function AdjustProgressBar(progressValue) {
                        
                        var progressBar = document.getElementById('<%=RadProgressBar1.ClientID%>');
                        progressBar.value = progressValue;

                    } 

    What would be the proper way of updating a ProgressBar from a callback function where as to show the updates values? Please advise and thank you in advance.











  2. Felix
    Felix avatar
    7 posts
    Member since:
    Nov 2012

    Posted 11 Feb 2015 in reply to Felix Link to this post

    My other option is to set the ProgressBar to "Intermediate", we would really like to display percentage to the user though. Please advise if this is possible. Thank you.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 13 Feb 2015 Link to this post

    Hello Felix,

    The RadProgressBar is designed to track a process by manually updating the value of the progress bar on the client when the state of the process changes. This means that the progress bar control does not automatically track the process, so when you set a value for the control, it directly displays it.

    To demonstrate a scenario, in which the progress bar is utilized I attached a simple example that uses a progress bar to track changes to a server-side integer variable and communicate back the current value. This is a simulation of a task progress. Please, note that the progress bar should be updated on the client-side using the set_value method (this is why your script did not update the progress bar, you need to use the client-side API of the control for this purpose).

    Also, for every new run of the provided sample page, you need to reset IIS, because the tracking integer is static and will not be reset until the web application gets restarted.


    If automatic updating of the progress is what you are after, you can use RadProgressArea instead. I would suggest checking the following comparison between RadProgressBar and RadProgressArea in order to choose the control that best suits your requirements: http://www.telerik.com/help/aspnet-ajax/progress-bar-vs-progress-area.html

    Regards,
    Slav
    Telerik
  5. Oliver
    Oliver avatar
    1 posts
    Member since:
    Aug 2016

    Posted 03 Nov in reply to Slav Link to this post

    I tried downloading and running you example but I cannot get the code to compile.   I am running into XMLHttpPanel does not exist from the .cs page.  Yet it clearly exists on the aspx page.  I just put your files into a generic application and called it WebApplication2.  I would really like to figure out how to increment the RadProgressBar from code behind.  Thanks.
  6. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 08 Nov Link to this post

    Hello Oliver,

     

    The example is from a Web Site project, while you are trying to use it in a Web Application. You can either use the example, attached to this post, or just create an empty WebForm in your application and copy the content of the original sample.

     

    Regards,
    Slav
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017