Welcome Guest Search | Active Topics | Sign In | Register

Progress Bar in aspx VB.NET Options
Jon Marson
Posted: Thursday, January 24, 2008 3:21:22 PM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Hi,

I'm stuck. I'm working in Visual Web Developer 2005 and when I load the example project, the progress bar works beautifully. I have no idea how to get it into my web site though. I haven't been able to find a guide or a forum topic that shows how to use the progress bar from an aspx page.

I've created a new Web Form named Progressbar.aspx using VB.NET. I drag and drop the Progressbar from the Control Toolbox EO.WEB panel onto the Web Form and set the property value color and style. So now I have this great looking progress bar but I have no idea how to talk to it from my VB.NET code...The sample code makes it look simple:

Code: Visual Basic.NET
Private Sub ProgressBar1_RunTask(sender As Object, e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask
  e.UpdateProgress(0, "Running...")
End Sub 'ProgressBar1_RunTask

I've copied the Progressbar control, stop/start buttons and javascript to my own project and cut the vb down to:

Code: Visual Basic.NET
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Partial Class Progressbar
    Inherits System.Web.UI.UserControl

    Private Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask

        e.UpdateProgress(0, "Running...")
        System.Threading.Thread.Sleep(500)
        e.UpdateProgress(100, "The task is done!")

    End Sub 'ProgressBar1_RunTask

End Class 'Demo

and the result:
Quote:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:
Line 6: Imports System.Web.UI.HtmlControls
Line 7:
Line 8: Partial Class Progressbar
Line 9: Inherits System.Web.UI.UserControl
Line 10:

Can anyone help me get this running? yes --> Thank you thank you thank you...thanks.
eo_support
Posted: Thursday, January 24, 2008 3:50:19 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi Jon,

You can find documentation on the progress bar control at here:

http://www.essentialobjects.com/ViewDoc.aspx?t=ProgressBar%2foverview.html

The same information is also avaliable in a local .chm help file.

As for the compiler error, unfortunately it's beyond the scope of our support. It's a generic compiler error and we only support questions related to our product here. Sorry!

Thanks
Jon Marson
Posted: Friday, January 25, 2008 8:44:45 AM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Thanks for the response. I think I was complicating things by adding too much. here is the simplified version that I got to work:

Code: HTML/ASPX
<%@ Page Language="VB" MasterPageFile="~/RXCheckout.master" AutoEventWireup="false" CodeFile="ProgressBar.aspx.vb" Inherits="ProgressBar" title="Untitled Page" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript">
function OnProgress(progressBar)
{
	var extraData = progressBar.getExtraData();
	if (extraData)
	{
		var div = document.getElementById("divStatus");
		div.innerHTML = extraData;
	}
}
</script>

  <eo:ProgressBar runat="server" id="ProgressBar1" ShowPercentage="True" IndicatorImage="00060104"
	BackgroundImageRight="00060103" ControlSkinID="None" BackgroundImage="00060101" IndicatorIncrement="7"
	BackgroundImageLeft="00060102" Width="300px" StartTaskButton="btnStart" StopTaskButton="btnStop"
	ClientSideOnValueChanged="OnProgress"></eo:ProgressBar>
  <br>

  <asp:LinkButton id="btnStart" runat="server">Start</asp:LinkButton>
  <asp:LinkButton id="btnStop" runat="server">Stop</asp:LinkButton>
  <div id="divStatus"></div>

</asp:Content>


Together with this VB.NET code:

Code: Visual Basic.NET
Partial Class ProgressBar
    Inherits System.Web.UI.Page

    Private Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) _
      Handles ProgressBar1.RunTask
        e.UpdateProgress(10, "Fish Heads")
    End Sub 'ProgressBar1_RunTask
End Class
Jon Marson
Posted: Friday, January 25, 2008 10:52:01 AM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
New question. The progress bar reacts as desired and can be adjusted from the VB.NET code but, when the sub has run its course it should be updating some text boxes on the page...but doesn't. What am I missing here?

Code: Visual Basic.NET
Private Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask
            e.UpdateProgress((x / NumMeasurements) * 100) 'works fine
            MaxIrrLabel.Text = FormatNumber(MaxIrradiance, 0) 'does not update at end of sub
    End Sub 'ProgressBar1_RunTask
eo_support
Posted: Friday, January 25, 2008 10:58:24 AM
Rank: Administration
Groups: Administration

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

The question has been discussed in this topic:

http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=993

Thanks
Jon Marson
Posted: Friday, January 25, 2008 11:19:34 AM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Thanks for the super quick response. Could you give me an example of how I would update:

<asp:Label ID="MaxIrrLabel" runat="server"></asp:Label>

from the sub ProgressBar1_RunTask

Thanks in advance.
eo_support
Posted: Friday, January 25, 2008 11:27:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi Jon,

Please take a look of our sample project (you can load and run it with VS.NET) and also the documentation, what you are asking is already there. We don't mind to offer samples to show you how to use our product, but we certainly would not encourage our users to ignore all the resources that are already there. So make sure you go over those first.

Thanks
Jon Marson
Posted: Friday, January 25, 2008 12:03:51 PM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Hi,

I don't think I asked the right question. I've been working with the sample code and have successfully updated some html. I actually drop in an animated gif to acompany the progress bar. So this is where I send the extra information. After the sub is finished I want to modify the text value of a label that is outside of the div html.

There are several labels and text boxes that have new information (with several different variables) at the end of the sub that need to be updated.

When the sub is complete is there a way to refresh the page so that all the labels and text boxes get their new variables?

Thanks.
eo_support
Posted: Friday, January 25, 2008 1:24:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi Jon,

Thanks for the clarification. The purpose of the sample is to show you how to execute any arbitrary JavaScript code based on the information sent from the server. To simplify the code, the sample only updated DIV html. But you can replace that code with anything you would like.

To update a label, you would do similar things by calling document.getElementById and then set the returned element's innerHTML --- there is no fundamental difference between that and the DIV shown in the sample at all. If you want to work with other elements, there may be some differences, but that's general JavaScript programming and obviously we won't be able to show you every details on that.

To causes the page to postback, you can either call __doPostBack or eo_Callback function. Both again are JavaScript programming. eo_Callback is associated with our Callback control and you can find detailed documentation in the help file. __doPostBack is pretty much part of ASP.NET and you will need to consult MS resources to get more details on that.

Hope this helps.

Thanks
Jon Marson
Posted: Friday, January 25, 2008 3:05:26 PM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Hi,

Thanks for helping me with this challenge. (challenging for me anyway.).


Code: Visual Basic.NET
Private Sub ProgressBar1_RunTask(ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) Handles ProgressBar1.RunTask
  MaxIrrLabel.Text = "Updated from ProgressBar1_RunTask"
  e.UpdateProgress(50, "__doPostBack")
End Sub 'ProgressBar1_RunTask


Then I use the EO VB sample Javascript code to execute the __doPostBack. The progress bar is updated but the label is not. Again, I cannot simply send one variable back to the javascript to update a label because there are many labels and many text boxes that need to be updated.

When I use a standard button, each label and text box is updated after the VB.NET sub has completed, how do I get these to update when I use your progress bar?

Thanks in advance.
eo_support
Posted: Friday, January 25, 2008 3:23:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Hi Jon,

You might want to find somebody else around you for the questions. What you are asking is pretty much generic programming questions (for example, you are asking "I know how to handle one, but don't know how to handle two") and we do not support that. From our point of view, we have already explained to you how our control works, showed you the sample code and also pointed out the similarities between your case and our sample code, yet the code you posted is still out right wrong, as if you did not read what we tell you to read at all --- So we are not sure how we can help you further. Please keep in mind that our support staff will not code for you.

Thanks
Jon Marson
Posted: Tuesday, January 29, 2008 9:04:11 AM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Ok, figured out a way to do this:

Visual Basic code passes a comma delimited string back to javascript:
Code: Visual Basic.NET
e.UpdateProgress((x / NumMeasurements) * 100, "<img src=""Images/Light_On.jpg"" Height=""50px"" Width = ""50px"">," _
& MaxIrr & "," & FinalIrr & "," & InstanttoEquil & "")


Then catch and parse using javascript:
Code: JavaScript
function OnProgress(progressBar)
    {
      //progressBar extra data structure: (ImageDiv, MaxIrrLabel, FinalIrrLabel, InstanttoEquilButton)
      var extraData = progressBar.getExtraData();
	  if (extraData)
      {
        var progressBar_array=extraData.split(",");
		var div = document.getElementById("divStatus");
		div.innerHTML = progressBar_array[0];
        document.getElementById("MaxIrrLabel_Div").innerHTML = progressBar_array[1];
        document.getElementById("FinalIrrLabel_Div").innerHTML = progressBar_array[2];
        document.getElementById("InstanttoEquilButton_Div").innerHTML = progressBar_array[3];
      }
  }
  </script>


which updates the appropriate <div> tags in the html:
Code: HTML/ASPX
<div id="MaxIrrLabel_Div">
  <asp:Label ID="MaxIrrLabel" runat="server"></asp:Label>
</div>


What I don't know how to do is pass an array back to the browser. This isn't a pretty solution but it works. I figure I can pass a comma delimited string with name:value pairs in comma delimited format but this seems like a hokey solution.

Just wanted to post my solution in case someone else out there is asking the same question.
eo_support
Posted: Tuesday, January 29, 2008 9:41:46 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Thanks for sharing!
Jon Marson
Posted: Tuesday, January 29, 2008 9:53:21 AM
Rank: Member
Groups: Member

Joined: 1/24/2008
Posts: 13
Quick question. What is the maximum string length that can be passed back to the Javascript?
eo_support
Posted: Tuesday, January 29, 2008 10:00:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
We are not aware of any restrictions on our side except for system resource related, for example, a huge string has the potential to run out of your server memory. Nodes in between, for example, a proxy server may have some restrictions as well, it may drop the whole package if it thinks it too big. So in any case, keep it as small as possible.


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.