Solved

Problems Loading Popup to Display Progress

Posted on 2004-08-02
12
780 Views
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 (VB.net) 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.

TIA!
0
Comment
Question by:TheTennMan
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 21

Expert Comment

by:tovvenki
ID: 11700772
Hi,
can you paste some code so that we can check what is happening?.
Also have a look at this article
http://www.informit.com/articles/printerfriendly.asp?p=174363
this explains a simple technique for displaying the Progress message.

regards,
venki
0
 
LVL 2

Expert Comment

by:waterhidden
ID: 11714891


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

0
 

Author Comment

by:TheTennMan
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", "window.open('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
Response.Flush()
'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,
Don
0
 
LVL 2

Expert Comment

by:Freak4VB
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","javascript:window.open('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 !

0
 
LVL 5

Accepted Solution

by:
ajitanand earned 500 total points
ID: 12081796
Hello,

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
      Response.Flush()
      '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())
            Threading.Thread.CurrentThread.Sleep(10)
      Next
      Response.Write(s)
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.

regards,
Ajit Anand
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:ajitanand
ID: 12130342
Could you give it a try?
0
 

Author Comment

by:TheTennMan
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!

Don
0
 
LVL 2

Expert Comment

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

Thanks
0
 
LVL 2

Expert Comment

by:Freak4VB
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 ??

Thanks
0
 

Author Comment

by:TheTennMan
ID: 12341267
Freak4VB,

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.
0
 
LVL 2

Expert Comment

by:Freak4VB
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 !!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Zoom web page in asp.net 2 37
Problem to Popup 37 81
How to trouble shoot .net contact form 3 31
Asp/Net Validation date Issue 9 38
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now