Resetting RadProgressManager/RadProgressArea

Thread is closed for posting
6 posts, 0 answers
  1. Linus
    Linus avatar
    17 posts
    Member since:
    Jul 2008

    Posted 17 May 2011 Link to this post

    Hi!

    I'm using RadProgressManager and RadProgressArea to monitor a custom progress in the following scenario:

    1. The user clicks "Create" button
    2. At server-side, X items are being added to a Zip-file. For each item, the custom progress is updated.
    3. When the Zip-file is created, it is written to the Response-stream.
    4. The Zip-file is available for download.

    If the user would click the "Create" button again, the progress area won't display. Is it possible to "reset" the RadProgressManager in any way after it has finished (without having to redirect to the same page again)?
  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 May 2011 Link to this post

    Hello Linus Karlsson,

    Please open a support ticket and send us a sample project that reproduces your issue. I am sending you a sample code in which I am using RadProgressArea and at the end of the processing send a file.
    Markup:
    <div>
         <telerik:RadScriptManager runat="server" ID="RadScriptManager1"></telerik:RadScriptManager>
         <telerik:RadProgressManager ID="Radprogressmanager1" runat="server" />
         <telerik:RadProgressArea ID="RadProgressArea1" runat="server" />
         <asp:button text="text" runat="server" ID="ButtonSubmit"/>
     </div>
    Code behind:
    protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               //Do not display SelectedFilesCount progress indicator.
              // RadProgressArea1.ProgressIndicators &= ~ProgressIndicators.SelectedFilesCount;
           }
     
           RadProgressArea1.Localization.Uploaded = "Total Progress";
           RadProgressArea1.Localization.UploadedFiles = "Progress";
           RadProgressArea1.Localization.CurrentFileName = "Custom progress in action: ";
     
           ButtonSubmit.Click += new EventHandler(ButtonSubmit_Click);
     
       }
     
       void ButtonSubmit_Click(object sender, EventArgs e)
       {
           UpdateProgressContext();
       }
       private void UpdateProgressContext()
       {
           const int total = 100;
     
           RadProgressContext progress = RadProgressContext.Current;
           progress.Speed = "N/A";
     
           for (int i = 0; i < total; i++)
           {
               progress.PrimaryTotal = 1;
               progress.PrimaryValue = 1;
               progress.PrimaryPercent = 100;
     
               progress.SecondaryTotal = total;
               progress.SecondaryValue = i;
               progress.SecondaryPercent = i;
     
               progress.CurrentOperationText = "Step " + i.ToString();
     
               if (!Response.IsClientConnected)
               {
                   //Cancel button was clicked or the browser was closed, so stop processing
                   break;
               }
     
               progress.TimeEstimated = (total - i) * 100;
               //Stall the current thread for 0.1 seconds
               System.Threading.Thread.Sleep(100);
           }
          //put here the file location
           Response.WriteFile("~/uploads/new.txt");
            
       }

    Regards,
    Peter Filipov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ralph
    Ralph avatar
    6 posts
    Member since:
    Aug 2007

    Posted 01 Jul 2014 Link to this post

    Hi Peter
    I am using the 2014 Q2 release for this same process but unfortunately the RadProgressArea does not somehow know that it can now stop being visible after completion of the on server processing and the streaming of the zip file to the user.
    Rather than having a file to write to the response, I have a memorystream so am using the following:

    Response.Clear();
    Response.AddHeader("content-disposition", "attachment; filename=" + pFile + "_" +                                                                                                          DateTime.Now.ToString("yyyy_MM_dd") + ".zip");
    Response.ContentType = "application/zip";
    Response.BinaryWrite(memStream.ToArray());
     Response.End();

     RadProgressContext progress = RadProgressContext.Current;
     progress.CurrentOperationText = "Streaming complete. ";
     progress.OperationComplete = true;
     RadProgressArea1.Visible = false;


    The last 4 lines do not appear to be having any effect. I do not want to write my zip file to disk as potentially it is quite large and disposing of it immediately is my preferred option..

    Can you suggest any way to hide/close the ProgressArea?

    Thanks

    Ralph Price
    Application Developer and GIS Analyst
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 04 Jul 2014 Link to this post

    Hello Ralph,

    I have tested a sample approach and it works fine:
    private void UpdateProgressContext()
       {
           const int total = 10;
     
           RadProgressContext progress = RadProgressContext.Current;
           progress.Speed = "N/A";
     
           for (int i = 0; i < total; i++)
           {
               progress.PrimaryTotal = 1;
               progress.PrimaryValue = 1;
               progress.PrimaryPercent = 100;
     
               progress.SecondaryTotal = total;
               progress.SecondaryValue = i;
               progress.SecondaryPercent = i;
     
               progress.CurrentOperationText = "Step " + i.ToString();
     
               if (!Response.IsClientConnected)
               {
                   //Cancel button was clicked or the browser was closed, so stop processing
                   break;
               }
     
               progress.TimeEstimated = (total - i) * 100;
               //Stall the current thread for 0.1 seconds
               System.Threading.Thread.Sleep(100);
           }
           //put here the file location
     
           byte[] existingData = System.Text.Encoding.UTF8.GetBytes("foo");
           MemoryStream s2 = new MemoryStream(existingData, 0, existingData.Length, true);
           s2.Seek(0, SeekOrigin.End);
            
     
           Response.BinaryWrite(s2.ToArray());
     
       }
    Also you could send us your sample in a support ticket to review it in details.


    Regards,
    Peter Filipov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Ralph
    Ralph avatar
    6 posts
    Member since:
    Aug 2007

    Posted 06 Jul 2014 Link to this post

    Thanks Peter

    it looks like less is better. Once I took the  Response.End(); off it worked as required.
    I had even added a Response.Flush(); before the .End() in attempting to get it working.

    Now just to get a disclaimer RadWindow to be part of the UI as well and we will all be happy.

    Thanks

    Ralph Price
  7. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 10 Jul 2014 Link to this post

    Hi Ralph,

    Do you want to put the progress area inside RadWindow? If so try with the following code:
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        function OnClientSubmitting(sender, args) {
            $find('RadWindow1').show();
        }
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
     
    <telerik:RadWindow ID="RadWindow1" runat="server">
        <ContentTemplate>
            <telerik:RadProgressManager ID="Radprogressmanager1" runat="server"  OnClientSubmitting="OnClientSubmitting" />
            <telerik:RadProgressArea ID="RadProgressArea1" runat="server" OnClientProgressUpdating="OnClientProgressUpdating" />
        </ContentTemplate>
    </telerik:RadWindow>
     
    <asp:Button Text="text" runat="server" ID="ButtonSubmit" OnClick="ButtonSubmit_Click" />

    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        UpdateProgressContext();
    }

    I hope this helps.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017