Hi!
I'm using RadProgressManager and RadProgressArea to monitor a custom progress in the following scenario:
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)?
I'm using RadProgressManager and RadProgressArea to monitor a custom progress in the following scenario:
- The user clicks "Create" button
- At server-side, X items are being added to a Zip-file. For each item, the custom progress is updated.
- When the Zip-file is created, it is written to the Response-stream.
- 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
0
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:
Code behind:
Regards,
Peter Filipov
the Telerik team
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
>
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
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
Hello Ralph,
I have tested a sample approach and it works fine:
Also you could send us your sample in a support ticket to review it in details.
Regards,
Peter Filipov
Telerik
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());
}
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
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
Hi Ralph,
Do you want to put the progress area inside RadWindow? If so try with the following code:
I hope this helps.
Regards,
Hristo Valyavicharski
Telerik
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.