• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

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 Code for the label text
0
mainrotor
Asked:
mainrotor
  • 3
  • 3
  • 2
  • +2
1 Solution
 
Jeff CertainCommented:
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?

0
 
Jeff CertainCommented:
Okay, I can see your code now (I'm on the road, with a very slow connection.)
0
 
mainrotorAuthor 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

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

lblError.Text = "Excel formatting completed successfully"
0
 
Jeff CertainCommented:
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.)
0
 
RickCommented:
You could try changing the text with javascript after you call each function.
0
 
informaniacCommented:
The problem I feel with Progress Bar in this situation is, he won't be able to display different messages for each funcs
0
 
mainrotorAuthor Commented:
rick_gwu,
How can I change the text with JavaScript, can you provide a sample?

mrotor
0
 
RickCommented:
There you go. Thanks CodeCruiser for providing the examples.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now