Welcome Guest Search | Active Topics | Sign In | Register

Call ProgressBar1_RunTask in VB.net while Button Options
CPT Group
Posted: Tuesday, March 3, 2020 5:27:59 PM
Rank: Newbie
Groups: Member

Joined: 2/19/2020
Posts: 6
New here, How to call ProgressBar1_RunTask in VB.net while Button press event.

Protected Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs.

We need to call RunTask event after data is saved to a database. We get the id of the new record when inserting in SQL and make a folder based on ID and save the files to that folder.

Thank you =)
eo_support
Posted: Wednesday, March 4, 2020 10:08:53 AM
Rank: Administration
Groups: Administration

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

You won't be able to do this directly from server side code. Because the client side code of the ProgressBar needs to be aware that a server side task is running, the RunTask event can only be triggered from client side. So what you need to do is actually a two step process:

---- Normal Button Click event flow begin -----

1. The Button is clicked and server side Button_Click event is triggered;
2. Your code in Button_Click event handler updates database;
3. The page is reloaded;

---- Normal Button Click event flow end -----

---- ProgressBar RunTask event flow ----

4. Calling progressBar.startTask from client side;
5. Server side ProgressBar_RunTask event is triggered;

The key here is you need to connect step 3 and step 4. This can usually be done by rendering some JavaScript code in step 2. For example, you can have a Label control in your Form and then in step 2 you can do something like this:

Code: C#
Label1.Text = "<script>progressBar.startTask()</script>";


This way when this code is rendered to the client through step 3, it will call startTask and enter step 4.

If your ProgressBar_RunTask handler depends on values in previous steps (such as a record_id you just inserted in step 2), then you may want to use session variable to pass that value as there is no way for you to pass such value directly between the first round trip (step 1 to step 3) and the second round trip (step 4 and step 5).

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!
CPT Group
Posted: Wednesday, March 4, 2020 7:02:03 PM
Rank: Newbie
Groups: Member

Joined: 2/19/2020
Posts: 6
Thanks so much. I'm trying your suggestion. It works for the most part. The ProgressBar RunTask is firing, but the UpdateProgress(i) is not updating the percentage.

Any idea what would cause this from not updating the percentage?


<eo:ProgressBar ID="ProgressBar1" runat="server" ShowPercentage="True" IndicatorImage="00060104"
BackgroundImageRight="00060103" ControlSkinID="None" BackgroundImage="00060101"
IndicatorIncrement="7" BackgroundImageLeft="00060102" Width="300px"
ClientSideOnValueChanged="OnProgress" OnRunTask="ProgressBar1_RunTask" ClientIDMode="AutoID"></eo:ProgressBar>


Protected Sub ProgressBar1_RunTask(sender As Object, e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask
Dim i As Integer
For i = 0 To 100

System.Threading.Thread.Sleep(100)

If e IsNot Nothing Then
If e.IsStopped Then
Exit For
Else
e.UpdateProgress(i)
End If
End If
Next i
End Sub
eo_support
Posted: Wednesday, March 4, 2020 9:13:51 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Does your client OnProgress handle ever get called?
CPT Group
Posted: Thursday, March 5, 2020 5:13:08 PM
Rank: Newbie
Groups: Member

Joined: 2/19/2020
Posts: 6
Yes. Thank you. But now where looking at the CallbackPanel and Dialog to use the loading.gif.

But the code behind Button1 does not recognize that our Fileupload has files when using Fileupload.hasfiles. It returns false. But when using a button outside the CallbackPanel, the vb code does recognize the Fileupload has files (Fileupload.hasfiiles = true)

Any idea why the Fileupload control is not recognizing that the control has files?

<asp:Content ID="Content1" ContentPlaceHolderID="demo" runat="Server">
<p>
A modal dialog with a back shade color can be effectively used as an input blocker
to temporarily block user input.
</p>
<p>
Enter some text below and then click "Submit" button.
</p>
<eo:CallbackPanel runat="server" ID="CallbackPanel1" LoadingDialogID="Dialog1" Triggers="{ControlID:Button1;Parameter:}">
<p>
Some Input:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></p>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></asp:Button></p>
<p>
<asp:Label ID="lblResult" runat="server"></asp:Label></p>
</eo:CallbackPanel>
<eo:Dialog runat="server" ID="Dialog1" BackShadeColor="Blue">
<ContentTemplate>
<table border="0">
<tr>
<td align="center">
<img src='<%=ResolveClientUrl("~/Images/loading.gif")%>' />
</td>
</tr>
<tr>
<td nowrap="true">
Please wait...</td>
</tr>
</table>
</ContentTemplate>
</eo:Dialog>
</asp:Content>


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.