This is a migrated thread and some comments may be shown as answers.

Resetting RadProgressManager/RadProgressArea

5 Answers 241 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Linus
Top achievements
Rank 2
Linus asked on 17 May 2011, 12:49 PM
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)?

5 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 20 May 2011, 11:14 AM
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.

0
Ralph
Top achievements
Rank 1
answered on 02 Jul 2014, 03:41 AM
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
0
Peter Filipov
Telerik team
answered on 04 Jul 2014, 10:22 AM
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.

 
0
Ralph
Top achievements
Rank 1
answered on 06 Jul 2014, 09:02 PM
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
0
Hristo Valyavicharski
Telerik team
answered on 10 Jul 2014, 07:03 AM
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.

 
Tags
Upload (Obsolete)
Asked by
Linus
Top achievements
Rank 2
Answers by
Peter Filipov
Telerik team
Ralph
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or