Solved

Refresh label on page

Posted on 2010-09-07
11
442 Views
Last Modified: 2012-05-10
Hi,
I have a page with a very long running script that loops round reading many individual files.
As this takes so long I would like to know where the job has progressed to.

I have a label on the page called lblStatus and each time the function loops and reads a new file
The new file name is held in a variable called "InputFile"
I would like lblStatus to say which file it is and update the page each time this changes. The job will continue to run so the page has not posted back yet.

in VB is there anything I can add to the folloowing so that this works
            lblStatus.Text = ""
            lblStatus.Text = "Processing " + InputFile

If not possible in VB what are my options?
0
Comment
Question by:Simon Cripps
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 33616658
lblStatus.Text = ""
lblStatus.Text = "Processing " & InputFile
0
 
LVL 33

Expert Comment

by:jppinto
ID: 33616673
You cannot add strings with the plus (+) sign.

Also I don't see the point in doing this as the records will pass so fast that you won't be able to read the labels as it changes on each file, unless each file update takes at least, say, one second or so.

But anyway, please try with the "&" as I mentioned...that should work. I assume that you have the rest of the code, some loop since the first file until the last one.

jppinto
0
 

Author Comment

by:Simon Cripps
ID: 33616847
Hi thanks for the input.
What is happening is that I am reading through 100 or so files eachone with several thousand records and so each file takes a couple of minutes to progress and I want to know which file (not record) is being processed.
As this is looping through all the 100 or so files it is not posting back the updates to the web page untill all files have been processes.
therefor how do I get the current "InputFile" to be displayed in the label lblStatus

lblStatus.Text = ""
lblStatus.Text = "Processing " & InputFile

0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 33616883
lblStatus.Text = ""
if (InputFile.tostring ="")
{
lblStatus.Text = "Processing " & InputFile
}
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 33616889
lblStatus.Text = ""
if (InputFile.tostring  ="")
{
lblStatus.Text = ""
}
else
{
lblStatus.Text = "Processing " & InputFile
}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Simon Cripps
ID: 33617026
no, no, no, no, no

Thanks for the input but the real issue is that I need to update a label while a sub routine is running though numerous files and need to identify which file
Sudocode below

Protected sub MyJob (.....
Get datafile of 100 file names

For each filename within data
      Process the data of the file named in datafile
       set InputFile as the current file name from datafile
       Display in lblStatus.Text the name of the file InputFile
Next File


I think I need to use Ajax UpdatePanel but how?

0
 
LVL 9

Expert Comment

by:abhinayp86
ID: 33620080
I am using this in my app.

U should put the label in update panel along with a timer with interval 1sec (interval="1000").
And for each tick(1 sec here) the label gets updated.

Let me know if u have any questions.

Thanks,
Abhinay
aspx page

<form id="form1" runat="server">
    <asp:AjaxScriptManager runat="server" ID="fasdfs">
    </asp:AjaxScriptManager>
    <asp:UpdatePanel ID="upProcessing" runat="server" RenderMode="Inline" UpdateMode="Always">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
            <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" />
            <asp:Label ID="lblProcessing" runat="server" /><br />
         </ContentTemplate>
    </asp:UpdatePanel>
    
    </form>

vb Code

Protected Sub Timer1_Tick(sender As Object, e As EventArgs)
	lblProcessing.Text = "Processing: " & InputFile
End Sub

Open in new window

0
 
LVL 2

Accepted Solution

by:
gmilhon earned 500 total points
ID: 33623178
All of the above solutions aren't true client/server updates while the postback is occuring. The best solution I have found is to use EssentialObject's ProgressBar. It is free and here is an example of it: http://demo.essentialobjects.com/Demos/Progress%20Bar/Server%20Side%20Task%20-%20Advanced%201/Demo.aspx.

You can use the client side java script to update an item on the client side. I use a paragraph <p> and set the innerhtml to the updated value.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 33633317
Are you creating a WinForms project or an ASP.Net webpage?  I ask because of this zones in which this question is posted.  I cannot speak for the ASP.NET stuff.  However, if you are attempting this in a VB.NET WinForms project, you can use a BackgroundWorker and call a ReportProgress at certain points within your loop based on whatever you want.  Within that ReportProgress routine, you can update your label as you are attempting.
 
I can continue with example if this is what you are actually doing.
0
 
LVL 5

Expert Comment

by:puffdaddy411
ID: 33633347
Crippsy:  "I think I need to use Ajax UpdatePanel but how?"
 
I appologize.  Please disregard my post above.



0
 

Author Closing Comment

by:Simon Cripps
ID: 33660449
Very usefull tools here, thanks for pointing them out
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Please explain "Multi-Tenant Services" 5 65
Class object 2 28
Get hold of longitude and latitude in iframe string 11 24
Regex validation 2 0
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now