Hi,
Im trying to use RadProgressArea to show a progress bar for custom DB task. It shows up and the progress is shown.
The issue is after completion of task, it still shows up and doesnt hide.
If i remove the RadAjaxManager updating the panel, then on completion of task the RadProgressArea goes off.
Following is the code snippet for my aspx and code behind
Im trying to use RadProgressArea to show a progress bar for custom DB task. It shows up and the progress is shown.
The issue is after completion of task, it still shows up and doesnt hide.
If i remove the RadAjaxManager updating the panel, then on completion of task the RadProgressArea goes off.
Following is the code snippet for my aspx and code behind
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="ProgressBarSample.WebForm4" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
id
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"buttonSubmit"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"Panel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
IsSticky
=
"true"
>
</
telerik:RadAjaxLoadingPanel
>
<
asp:Panel
runat
=
"server"
ID
=
"Panel1"
>
<
asp:Label
ID
=
"lbl1"
runat
=
"server"
></
asp:Label
>
</
asp:Panel
>
<
asp:button
ID
=
"buttonSubmit"
runat
=
"server"
Text
=
"Submit"
OnClick
=
"buttonSubmit_Click"
CssClass
=
"RadUploadButton"
/>
<
telerik:RadProgressManager
id
=
"Radprogressmanager1"
runat
=
"server"
/>
<
telerik:RadProgressArea
id
=
"RadProgressArea1"
runat
=
"server"
/>
<
br
/><
br
/><
br
/><
br
/><
br
/><
br
/>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
Telerik.Web.UI.Upload;
namespace
ProgressBarSample
{
public
partial
class
WebForm4 : System.Web.UI.Page
{
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: "
;
}
protected
void
buttonSubmit_Click(
object
sender, System.EventArgs e)
{
UpdateProgressContext();
lbl1.Text =
"Updated"
;
}
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;
int
per = Convert.ToInt32((Convert.ToDouble(i) / total)*100);
UpdateProgress(progress,total,i,per);
progress.CurrentOperationText =
"Step "
+ i.ToString() +
" Per = "
+ per.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);
}
}
private
void
UpdateProgress(RadProgressContext progress,
int
total,
int
i,
int
per)
{
progress.SecondaryTotal = total;
progress.SecondaryValue = i;
progress.SecondaryPercent = per;
}
}
}