Welcome Guest Search | Active Topics | Sign In | Register

apply delay to progress bar Options
Edwin Joseph
Posted: Friday, September 18, 2009 7:58:37 AM
Rank: Newbie
Groups: Member

Joined: 9/18/2009
Posts: 1
hi,
i am using the "free Progressbar" control. Here we need the progress bar to start working when the page is loaded. we have managed this using the jscript

function pageLoad()
{
var pb = eo_GetObject('<%=ProgressBar1.ClientID %>');
if(null!=pb)
pb.startTask();
}
Code: C#

Here the "ProgressBar1_RunTask" event is called continuously. so because of this we are finding difficulty in navigating to other pages, etc. so please send me solution for this. such that we can delay the event call for a certain period of time in between the automatic event call.


"Here this is a user control" and below i have mentioned the code

Markup code

<body onload="pageLoad()" onunload="pageunLoad()">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="padding-top: 15px;">
<eo:ProgressBar runat="server" ID="ProgressBar1" ShowPercentage="True" IndicatorImage="00060304"
BackgroundImageRight="00060303" ControlSkinID="None" BackgroundImage="00060301"
OnRunTask="ProgressBar1_RunTask" BackgroundImageLeft="00060302" Width="300px"
ClientSideOnValueChanged="OnProgress" ForeColor="Black">
</eo:ProgressBar>
<br>
<asp:Panel runat="server" ID="panStartProgressBar" Visible="true">

<script type="text/javascript" language="javascript">
function pageLoad()
{
var pb = eo_GetObject('<%=ProgressBar1.ClientID %>');
if(null!=pb)
pb.startTask();
}
function pageunLoad()
{
var pb = eo_GetObject('<%=ProgressBar1.ClientID %>');
if(null!=pb)
pb.stopTask();
}
</script>

</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</body>

code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Threading;
using IIMS.BusinessLogic;
using System.Drawing;

namespace IIMS.UserControls
{
public partial class ProgressbarCode : System.Web.UI.UserControl
{
int _recordCount;

public enum ProgressTypeAvailable
{
Syncing, Fetching
}

private ProgressTypeAvailable ProgressTypes;

public ProgressTypeAvailable ProgressType
{
get { return ProgressTypes; }
set { ProgressTypes = value; }
}

override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.ProgressBar1.RunTask += new EO.Web.ProgressTaskEventHandler(this.ProgressBar1_RunTask);
this.Load += new System.EventHandler(this.Page_Load);
}

private int i = 0;

protected void ProgressBar1_RunTask(object sender, EO.Web.ProgressTaskEventArgs e)
{
UpdatePB(sender, e);
//System.Threading.Thread.Sleep(200500);

}

public void UpdatePB(object sender, EO.Web.ProgressTaskEventArgs e)
{
if (i >= 100)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "javascript:pageunLoad();", true);
return;
}
while (_recordCount < 101)
{
e.UpdateProgress(i, "Running...");
_recordCount = GetProgressInformation();
if (_recordCount >= 100)
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "javascript:pageunLoad();", true);
if (_recordCount > i)
{
for (; i < _recordCount; i++)
{
if (e.IsStopped)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "javascript:pageunLoad();", true);
break;
}
//System.Threading.Thread.Sleep(500);
if (i > 50)
e.UpdateProgress(i, "Half done...");
else
e.UpdateProgress(i);
}

if (i == 100)
{
e.UpdateProgress(100, "The task is done!");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "javascript:pageunLoad();", true);
break;
}
}
}
}

private int GetProgressInformation()
{
DataTable dtProgressInformation = new DataTable();
Double ProcessedRecords = 0;
Double TotalRecords = 0;
Double count = 0;
dtProgressInformation = SyncProcessStageBL.GetProgressInformation(ProgressType.ToString());
if (dtProgressInformation != null && dtProgressInformation.Rows.Count > 0)
{
//gets the stage value from db
if (DBNull.Value != dtProgressInformation.Rows[0]["ProcessedRecords"])
ProcessedRecords = Convert.ToDouble(dtProgressInformation.Rows[0]["ProcessedRecords"]);
if (DBNull.Value != dtProgressInformation.Rows[0]["TotalRecords"])
TotalRecords = Convert.ToDouble(dtProgressInformation.Rows[0]["TotalRecords"]);
}
count = ProcessedRecords / TotalRecords;
count = count * 100;
return Convert.ToInt32(count);
}

protected void Page_Load(object sender, EventArgs e)
{

}
}
}
eo_support
Posted: Friday, September 18, 2009 8:41:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We do not offer free tech support on our free controls (sorry). Please see here for more details:

http://www.essentialobjects.com/forum/postst3728_Can-I-get-tech-support-on-your-free-controls.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.