Setting the value from codebehind

6 posts, 0 answers
  1. Senad
    Senad avatar
    10 posts
    Member since:
    Jul 2012

    Posted 31 Oct 2014 Link to this post

    Hi everyone (Telerik team),
    I am currently evaluating the new ProgressBar control, but I face a problem of setting its value from the codebehind (C#).
    It is not a problem how to set the value of the control, but my opservation that the ProgressBar is not advancing like in the Telerik's demo (using JavaScript).

    On a simple webform I added a new ProgressBar and older RadProgressArea (with RadProgressManager on top of it) control, in addition to a Button for starting the action. The code is as follows:

    public partial class _Default : System.Web.UI.Page
    {
        RadProgressContext progress = RadProgressContext.Current;
     
        protected void Button_Click1(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)
            {
                // 1. RadProgressBar (new control):
                RadProgressBar1.Value = i;
     
                // 2. RadProgressArea (previous control):
                progress.PrimaryValue = i;
                progress.PrimaryPercent = i;
     
                progress.SecondaryValue = i;
                progress.SecondaryPercent = i;
     
                System.Threading.Thread.Sleep(100);
            }
        }
        protected void Button_Click2(object sender, EventArgs e)
        {
            // Clear the progressbar:
            RadProgressBar1.Value = 0;
        }
    }

    After running the code, the older RadProgressArea is working fine, ie. the bar is advancing at each step as we expected.
    However, the new RadProgressBar is not advancing and will only show its final value (in this case 99) at the end of the process.

    Could someone point me in the right direction in solving this problem. I repeat, I need above functionality without using javascript.

    Regards,
    Senad




  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 05 Nov 2014 Link to this post

    Hello Senad,

    The RadProgressArea control automatically tracks the process on the server via RadProgressManager. The RadProgressBar has to be updated manually either on the client or on the server, depending on the scenario, in which it is used.

    If you want to update the progress bar dynamically you can do so on the client via the set_value method. The following demo shows it in action: http://demos.telerik.com/aspnet-ajax/progress-bar/functionality/chunk/defaultcs.aspx

    Also, I would suggest checking the help article that compares the two progress tracking controls in the UI for ASP.NET AJAX suite in order to get a better understanding of how each works and choose the one that matches your requirements: http://www.telerik.com/help/aspnet-ajax/progress-bar-vs-progress-area.html

    Regards,
    Slav
    Telerik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Senad
    Senad avatar
    10 posts
    Member since:
    Jul 2012

    Posted 05 Nov 2014 in reply to Slav Link to this post

    Dear Slav,
    I thank you for the reply, but my main problem remains unsolved.
    As I said in the original post, I know that we can update the RadProgressBar value manually (ie. RadProgressBar1.Value = i;), but the problem is that bar is not advancing on the screen at each step.

    Your suggestion is to use the JavaScript functionality via set_value method, which, to be honest, is way too complicated option. As a matter of fact, it is mandatory for me to update the value from the server side, so those (calculated) values need to be passed to this client function. Unfortunately, I was unable to find a way to do it so far.

    On the other hand, the older RadProgressBar doesn't have such problems: all we have to do is simply update its value from the code behind (ie. progress.PrimaryValue = i;) and the bar is actually advancing visually on the screen at every loop without any client intervention.

    If your answer is the only option then your documentation should be extended saying so, particularly because there is a comparison between the RadProgressBar and RadProgressBar.

    Regards,
    Senad


  5. Sam
    Sam avatar
    50 posts
    Member since:
    Apr 2008

    Posted 06 Nov 2014 in reply to Senad Link to this post

    And just to be very clear about this question: Are we able to update/refresh the new ProgressBar values from the server side (code-behind)?

    Thanks,
    -Sam
  6. Senad
    Senad avatar
    10 posts
    Member since:
    Jul 2012

    Posted 07 Nov 2014 in reply to Sam Link to this post

    Sam,
    yes, we are able to update its value (in the 'for' loop we simply put RadProgressBar1.Value = i;), but the problem is that on the screen the bar is actually not advancing visually. At the end of the loop, it will only show its final value on the screen. To repeat, the problem is that for the new RadProgressBar control, the bar is not advancing through the loops.

    On contrary, the older RadProgressArea is doing exactly this: it is visually advancing on the screen after each loop.

    Regards,

    Senad
  7. Niko
    Admin
    Niko avatar
    387 posts

    Posted 10 Nov 2014 Link to this post

    Hello Senad,

    The behavior that you describe as a problem in the RadProgressBar is actually part of the intended functionality of the control. Please, keep in mind that the RadProgressBar and the RadProgressArea are two different controls and the requirements associated with them are different and, as is in your case, non-overlapping.

    As can be seen by the comparison table - RadProgressArea requires registration of HTTP handler. This is actually the HTTP handler that does periodical AJAX callback to the server in order to get the progress on the RadProgressContext. Since the context is changed in the mentioned for-loop, the periodic ajax requests get the changes and apply them visually on the RadProgressArea. You get this functionality out-of-the-box with the help of the RadProgressManager.

    The same behavior is not part of the RadProgressBar. The idea is to provide our customers with a light-weight, thin control that offers progress tracking. There is no server-side tracking of progress in the RadProgressBar control, because it does not make sense in the context this control has been thought for. Still you can use the ProgressBar control to track server-side processes. You need to implement the periodic server calls on your own. In that respect you can take full advantage of any technology that you see fit, which is able to communicate changes from the server to the client side. You can use periodic calls to web services, SignalR, custom implementation, server-side events, etc. You are basically not limited to a single implementation.

    As an illustration of the information so far, you can find attached a simple example that I have prepared, which uses the RadProgressBar control 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 RadProgressBar should be updated on the client-side using the set_value method, thus taking full advantage of the excellent user experience of the control.

    Please, note that 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.

    Hope this helps.

    Regards,
    Niko
    Telerik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017