Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

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

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 User generated image
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

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.)
Avatar of mainrotor
mainrotor

ASKER

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

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.)
You could try changing the text with javascript after you call each function.
Avatar of Obadiah Christopher
The problem I feel with Progress Bar in this situation is, he won't be able to display different messages for each funcs
rick_gwu,
How can I change the text with JavaScript, can you provide a sample?

mrotor
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There you go. Thanks CodeCruiser for providing the examples.