Solved

Label Text does not get updated

Posted on 2013-12-14
9
425 Views
Last Modified: 2013-12-20
I am trying to set the text of a label control based on a condition in a loop.

The condition is reached about 10 times during the loop.

The final text value is ->->->->->->->->->->->->->->

The label acts as a progress bar.

There is no error, but the label text does not get updated.

string strProgressChar = "->";
   
      for (int i = 0; i <=8000 ; i++)
       {
                intProgress++;
               
                if (intProgress == intProgressIncrement)  // increment is 300
                {
                    lblProgress.Text = lblProgress.Text + strProgressChar;  // Text is not updated
                    intProgress = 0;
                }

        }  // End  while ((line = sr.ReadLine()) != null)


Any help would be appreciated.

Thanks,
0
Comment
Question by:Dovberman
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39718834
I'm not going to be much help here because I don't have access to VS for testing. When update bars do not show progress it's almost always because the processing thread you are attempting to report on is busy so it cannot also update the progress. In other words, it cannot do two things at once. You need to introduce a pause/update/resume logic at short intervals in your coding for the main process or add a second processing thread for the update (Google multi-threaded operations for asp.net) or you could do a progress bar using ajax for polling. Look here.You may need to provide the main process code to get the help you need.

That's my entire contribution to this question.
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
ID: 39718872
You can't do it like this in asp.net

in ASP.Net when you're running that process the entire thing is server side, the page doesn't reload again until after all of the server side code is finished running.

If you wanted to use the label as a progress bar you would need a web service of some kind.

See below for more information:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28283009.html
0
 

Author Comment

by:Dovberman
ID: 39719177
I thought I would need a delay step.  I will try the timer and provide feedback.

Thanks,
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719294
You can try either the .Refresh method of the label control, or you could invoke whatever your language's equivalent of "DoEvents" is.  I have to use DoEvents in VB programming, but overuse can be a problem, that's why I only use it at certain intervals using the MOD function, i.e. If intRec MOD 100 = 0 Then DoEvents
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Dovberman
ID: 39719559
There is no .Refresh method for a label control.
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719921
Then instead try the Refresh method of the form.
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
ID: 39720314
If this is for asp.net there is no .refresh on the form.
0
 
LVL 8

Accepted Solution

by:
johny_bravo1 earned 300 total points
ID: 39723304
Well Asp.Net gives you more option for display a progress bar rather than using label.

If you are using UpdatePanel use UpdateProgress control.

Alternatively you can use javascript/ jquery, check below links for javascript

http://www.javascriptkit.com/script/script2/progressbar.shtml

http://jqueryui.com/progressbar/#default
0
 

Author Closing Comment

by:Dovberman
ID: 39731224
Thank you
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

20 Experts available now in Live!

Get 1:1 Help Now