0

I have a label control in an updatepanel called lblStatus. I have the follwing code in my codebehind:

for x = 0 to 100
lblstatus.text = x
Threading.Thread.Sleep(1000)
updatepanel.update
next

I cannot seem to get the status to show. It only shows the last number once the loop is complete. Please help.

1 Answer 1

2

You can't update an update panel in a loop. The updates for the page isn't sent to the browser until the response is complete on the server, so you can only do one update for each request to the server. Your code will simply change what the update will be several times, and the final update is then sent to the browser when the server code ends.

Sign up to request clarification or add additional context in comments.

6 Comments

So how would i go about properly pushing the update to the status label? I see other web apps doing so.
@Scott: You need to make a request to the server for each update. You can set up a timer that will trigger the requests. You should however consider using AJAX calls to fetch the data from the server instead of doing webform callbacks for each update.
not sure i understand how to do that. the code was purely an example, what i have is a range of ip addresses i need to ping and show a boolean status of whether the ping was successful.
@Scott: You can either send one request to the server for each IP address to test, or you can send a single request to the server and let the server test all IP addresses at once and return the result for all of them.
very close to an answer here. if i had 4 ip addresses to ping and my app pinged the first one, how would it know when the first command had completed and to send the second ping command?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.