|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
Hi I got a problem with a project that I recently inherited(the project was half complete at that time). We import records from excell and after every record that is imported the progressbar should be incremented. When I put a standard button on my page and call the runtask event, every thing works great as it should. However the import is done through a wizard, which guides the user through the steps and at a certain step the import is done. The runtask event won't fire with the wizard buttons. Ok so I want to impictly invoke the runtask event through my code, but I can't or rather don't know how to. If you can maybe help PLEASE!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You absolutely won't be able to and should not invoke the runtask event through your code.
I am not sure why it didn't work with the wizard. Please create a sample page that demonstrates the problem and we will look into it as soon as we have that.
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
I did set the StartTaskButton to the next Button of the wizard, but it doesn't work Any other suggestions on how to implement the progressbar?
Code: C#
using System;
using System.Data;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button nextButton = (Button)wzImport.FindControl("StepNavigationTemplateContainerID").FindControl("StepNextButton");
ProgressBar1.StartTaskButton = "nextButton";
}
protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
switch (e.NextStepIndex)
{
case 1:
//do something
break;
case 2:
//progressbar RunTask event should execute
//I did set the StartTaskButton to the nextButton of the wizzard
// in the progressbars properties
break;
case 3:
//do something...wizard ends
break;
}
}
protected void ProgressBar1_RunTask(object sender, EO.Web.ProgressTaskEventArgs e)
{
for (int i = 0; i < 100; i++)
{
System.Threading.Thread.Sleep(100);
e.UpdateProgress(i);
}
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
I see what you mean. No. You can not use one button for both purposes (switch the wizard and start progress bar). Try include the following code after the progress bar inside the same WizardStep where the progress bar is:
Code: HTML/ASPX
<script type="text/javascript">
eo_GetObject("ProgressBar1").startTask();
</script>
Note you will need to change "ProgressBar1" to whatever your progress bar ID may be. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
Thank you will try
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
I did as you said but it still doesn't work. It gives me this error: An EO.Web control is rendered after an AJAX callback but there wasn't any EO.Web control on the page before the callback. The AJAX rendered EO.Web control will not function correctly under this situation. To correct this problem, please place at least one EO.Web control (an empty EO.Web Callback control, for example) outside of the AJAX update panel so that EO.Web client side script is correctly initialized before the AJAX call. Here is how it is declared in ASPX:
Code: HTML/ASPX
<asp:WizardStep runat="server" Title="6 Preview" StepType="Step"><asp:Label runat="server" Text="Preview (6 of 8)" SkinID="labelWizardHeading" Width="384px" ID="lblPreview" EnableTheming="True" __designer:wfdid="w5"></asp:Label>
<eo:ProgressBar runat="server" ControlSkinID="None" ClientSideOnValueChanged="OnProgress" IndicatorImage="00060304" Width="471px" BackgroundImageRight="00060303" BackgroundImage="00060301" BackgroundImageLeft="00060302" ID="Import_ProgressBr" ShowPercentage="True" style="LEFT: 240px; TOP: 117px" OnRunTask="Import_ProgressBr_RunTask"></eo:ProgressBar>
<script type="text/javascript">
eo_GetObject("Import_ProgressBr").startTask();
</script>
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
Ok I fixed the error, silly mistake! But the code still doesn't work. The page gives me a:
'null' is null or not an object error (object expected)
I am not sure what it means or how to fix it. Am I implementing it wrong? How should I implement it?
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
The progressbar works wonderful when I use it with a nornal button, but then I have the problem that my wizzard doesn't go to the next step.
Am I going to have to redesign the hole flow of my page, or is there a way of moving the wizzard to the next step manually?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
I tried your code with the latest version and it works fine. You can try to enhance the JavaScript as follow:
Code: JavaScript
function StartProgressBar()
{
var pb = eo_GetObject("ProgressBar1");
if (pb && pb.isLoaded())
pb.startTask();
else
window.setTimeout("StartProgressBar()", 100);
}
StartProgressBar();
The whole test page would be like this:
Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
<eo:progressbar runat="server" backgroundimage="00060401" backgroundimageleft="00060402"
backgroundimageright="00060403" controlskinid="None" indicatorimage="00060404"
ID="ProgressBar1"
showpercentage="True" value="30" width="250px" OnRunTask="ProgressBar1_RunTask"></eo:progressbar>
<script type="text/javascript">
function StartProgressBar()
{
var pb = eo_GetObject("ProgressBar1");
if (pb && pb.isLoaded())
pb.startTask();
else
window.setTimeout("StartProgressBar()", 100);
}
StartProgressBar();
</script>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</div>
</form>
</body>
</html>
Please try the same with the latest version and see if it works. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
thanx! Trying quickly.
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2008 Posts: 8
|
Thanx a lot! I works beautifully!
|
|
Rank: Newbie Groups: Member
Joined: 12/1/2008 Posts: 2
|
Hi, This works fine, the Progressbar starts when you enter the wizards step, but this is not what i am looking for. I want the progress bar to start after the onclick of the next button not automatically when you go to the step. I am doing some processing in a wizard step on the click of Next and want the progress bar to start then.
Also want to e.UpdateProgress(i); to rely on the amount of processing that needs to be done. In the code behind ye are saying to get rid of thread.sleep and put in process that takes the time. But lets say process is = do 230 things. process() { do something with database 230 times (more or less) }
In ProgressBar1_RunTask for(i..) process() e.update
I dont want to to the process 100 times. Any ideas?
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I am not sure whether I got your question correctly about starting the progress bar. In any case as soon as you wish to start the ProgressBar, you render a piece of JavaScript to call "StartProgressBar();". For example, you can have a Label "Label1" in your WizardStep and you can start the ProgressBar by:
Label1.Text = "<script type='text/javascript'>StartProgressBar();</script>";
Note the body of JavaScript function StartProgressBar must be already in the page. The above sample has the function body and the function call together. In your case they would be separate. You can move the body into your head section.
When you call e.UpdateProgress, you tell the ProgressBar how much you are done. For example, if you need to do something with your DB 230 times, you would call e.UpdateProgress(50) when you reach 115, which means you are 50% done.
Hope this helps.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 12/1/2008 Posts: 2
|
Thank you for your quick reply,
I have done what you said and separated the javascript into the header getting rid of StartProgressBar(); part in JS. Added a label to the wizard step and set the text to call StartProgressBar(); in..
protected void ImportWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { if (ImportWizard.ActiveStepIndex == 1) { Label lb = (Label)ImportWizard.FindControl("ProgressBarLabel"); lb.Text = "<script type='text/javascript'>StartProgressBar();</script>"; } } but the "ProgressBar1_RunTask()" method does not run, tested with break points. The above code executes but after that it just goes to the next step in the wizard. ProgressBar1_RunTask does execute on the "previous" button when it goes back to load that step from the start.
<eo:progressbar> still in the wizard step.
Sorry about the confusion.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The basic idea is that you use a Label to render a piece of JavaScript in order to run it. It's a generic ASP.NET technique and the JavaScript code you rendered can be anything. For example, you can replace "StartProgressBar();" with "window.alert("hi!");". If it runs that, then it would run “StartProgressBar()” because it’s just another JavaScript function; If it doesn’t run that, you’ve got a problem in your code and since it’s a generic ASP.NET/JavaScript problem, you will need to seek other resource to solve such issue because our support won’t be able to troubleshoot generic coding issues. You may wish to review our official support policy: http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1368Thanks!
|
|