We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

I need help displaying a label on my ASP.Net 3.5 application

Medium Priority
289 Views
Last Modified: 2012-05-11
Hi Experts,
I have an ASP.Net 3.5 application with VB.Net codebehind.  In my application I have a button that initiates some processing, and a label.  When the button gets pushed, it calls various functions.  I want the text of the label to change at the start of every function (sort of like a process status display).  I have written code to do this, but the text of the label only changes after all the processing is complete.  What can I do to fix this?

Thank you in advance,
mrotor Code for the label text
Comment
Watch Question

The problem is almost certainly that the page lifecycle is biting you. You likely need to move the processing to another thread (i.e. make it asynchronous) so that the button click returns immediately.

If you cut and paste the code, I can help you with this.

Are there any other requirements, such as changing the text back after the processing is complete?

Okay, I can see your code now (I'm on the road, with a very slow connection.)

Author

Commented:
Here is my code so you can just copy and paste it.
Protected Sub cmdFormat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdFormat.Click

        lblError.Text = "Formatting report, please be patient..."

        Call ReportFirstSection()
	  lblError.Text = "First section completed..."

        Call ReportSecondSection()
	  lblError.Text = "Second section completed..."

        Call sL2_FormatReport()
        lblError.Text = "Excel formatting completed successfully"
    End Sub

Open in new window

Author

Commented:
Chaosian,
Yes, the text should display the following after the processing is complete:

lblError.Text = "Excel formatting completed successfully"
The basic solution is going to involve some form of AJAX. (AJAX is a technology that allows you to retrieve data from the server, and update part of a page rather than having to refresh the whole thing. It's the fundamental technology that allows websites to act like desktop apps from a user experience perspective.)

Here's a couple options that might help:
http://www.redips.net/javascript/ajax-progress-bar/
http://www.aspnettutorials.com/tutorials/themes/progress-bar-csharp.aspx

(The second one of these is loaded with advertising, but has the benefit of providing a link to a VB version at the bottom of the page.)

Commented:
You could try changing the text with javascript after you call each function.
Obadiah ChristopherDeveloper User Interface
CERTIFIED EXPERT

Commented:
The problem I feel with Progress Bar in this situation is, he won't be able to display different messages for each funcs

Author

Commented:
rick_gwu,
How can I change the text with JavaScript, can you provide a sample?

mrotor
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
There you go. Thanks CodeCruiser for providing the examples.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.