Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Problems Loading Popup to Display Progress

Posted on 2004-08-02
Medium Priority
Last Modified: 2012-08-13
I'm having trouble with getting the proper flow that will allow me to open a popup that will display progress.  Under a button on a web form, I open a refreshing popup via Javascript.  The code under that same button then proceeds to perform the operation of which I want to show the progress.

If I register the Javascript from code ( in the page_load event, nothing happens with the popup until after the entire operation has completed, even though I am buffering and flushing the content after the call for the page to be opened in the page_load event but before the operation begins.  If I add the script as an "onclick" attribute of the button, then the new window is created, but it doesn't load the controls in the popup until the operation completes.

Do I need to allow all of the code in the code behind to finish and then find a way to kick off the operation I want to track?  If so, I'm guessing that would mean some additional user input, such as a confirmation to begin the process.  It doesn't seem like I should have to do that, so I may be overlooking something very simple.

Question by:TheTennMan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
LVL 21

Expert Comment

ID: 11700772
can you paste some code so that we can check what is happening?.
Also have a look at this article
this explains a simple technique for displaying the Progress message.


Expert Comment

ID: 11714891

you have to make your operations BOTH clientside or BOTH codebehind.


Author Comment

ID: 11718609
Thanks for the link, venki.  I've reviewed a lot of info on various sites, but I obviously haven't found exactly what I need yet.  I'll see if this site fills in some additional missing pieces.

In the meantime, here are the very basics of the current code you requested:

'Code in Load.aspx
Private Sub Page_Load
btnLoad.Attributes.Add("onclick", "'LoadProgress.aspx',null,'width=300,height=200,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no');")
If Not Page.IsPostBack Then
'Code to initialize page
End If
End Sub

Private Sub btnLoad_Click
'Call long procedure whose progress needs to be tracked
End Sub

waterhidden, I'll explain how I envision the processing flow and maybe you can tell me if I'm leaving something out or making a wrong assumption:

 - Load.aspx loads and presents options to user.
 - User selects options and initiates load (btnLoad_Click).
 - LoadProgress.aspx (runat=server) should load and is set to refresh periodically to update progress.
 - Load.aspx begins load process and sets application variables for LoadProgress.aspx to reference.

Thanks again,
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

ID: 11901301
If you need to invoke a javascript routine right after your HTML body loads you can use the Page.RegisterStartupScript function. Use it as
Page.RegisterStartupScript ("RefershScript","'LoadProgress.aspx',null,'width=300,height=200,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no');"

But if you want the script to fire "before" your HTML body is loaded use the Page.RegisterClientScript Function. The syntax is exactly the same. These functions fires the given javascripts respectively after and before the page loads !


Accepted Solution

ajitanand earned 1500 total points
ID: 12081796

Overview of your requirement:
Load.aspx - The WebForm that has a Load Button. Clicking this button in the browser opens a popup window [LoadProgress.aspx] on the Client side, and begins a Long Process on the Server side. During the long process the Load.aspx also increments the Application object's variable to share the process execution progress.

LoadProgress.aspx - The popup window, reads Application variable and shows the progress of the Server process (of Load.aspx) on the client browser.

Here is the solution:
There are 2 things that need to be taken care of:
Step 1. In the LoadProgress.aspx, you need to DISABLE the SessionState management, otherwise ASP.Net wont let it execute unless previous code is finished. This is MANDATORY.

Step 2. In the Load.aspx, you need to make the Thread Sleep for a short moment, in between the long running process, so that the LoadProgress.aspx gets some processor time to get executed, when the Popup window refreshes itself. This is REQUIRED for a Processor intensive tasks.

And here is the code:
For Step 1. You need to set the EnableSessionState to false in the page directive as follows:

<%@ Page Language="vb" EnableSessionState="False"

For Step 2. Here is how your code in Load.aspx.vb should look like:

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
      'Call long procedure whose progress needs to be tracked
      Dim i As Integer
      Dim s As String = ""
      For i = 0 To 10000
            s &= DateTime.Now.ToString() & "\n"
            s = s.Replace("!", "<br>")
            Application.Set("iCounter", i.ToString())
End Sub

Notice the call to Threading.Thread.CurrentThread.Sleep(10), the argument to this method is the time in milliseconds. If you increase this value to a value from 10 to 100, the update ofthe progress window will be much smoother, but the long process will execute slower.

On the other hand if you decrease it to say 1, the update for Progress window will be slower, but the process itself will execute faster.

Suggestion: Execute the LoadProgress.aspx once before trying the Load.aspx so that the time taken by ASP.Net to compile does not affects your testing.

Let me know if this helps/does not help.

Ajit Anand

Expert Comment

ID: 12130342
Could you give it a try?

Author Comment

ID: 12130376
Thanks for the response, Ajit.

I haven't had a chance to look at this based on shfiting priorities and deadlines.  However, it's about time to pull this out again.  When I do, I'll definitely try your approach.   It makes sense just based on a quick review of your proposed solution, so I'm really hopeful that this will take care of things.  I plan to set some time aside to be able to work on this within the next few days.

I'll let you know what happens.  Thanks again!


Expert Comment

ID: 12334977
  The solution that i proposed was concise and consistent. Am i going to get some credit ??


Expert Comment

ID: 12341193
Hey !
        Whazzup ? am a bit confused here. I got a mail from Experts Exchange telling me that my answer has been accepted but when I come here I see that it is not me who scooped up the points but someone else.
can anyone explain this to me please ??


Author Comment

ID: 12341267

I was getting ready to post this when your comment was added.  Ajit's solution was the type of input that I was seeking and sent me in the right direction, so that was the basis of my decision for awarding the points.  While your solution was definitely consise and consistent, my problem didn't involve the way the script was registered with the page.

I certainly appreciate your input, but Ajit deserved the points on this one.  Thanks again.

Expert Comment

ID: 12341293
Thats not at all a problem TennMan. I was only a bit confused about the mail I got from Experts-Exchange telling me that you have accepted my answer. I guess they need to do some more black box testing :-) !!!

Happy coding !!

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

688 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