Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net - giving feedback while processing

Status
Not open for further replies.

Nelviticus

Programmer
Joined
Sep 9, 2003
Messages
1,819
Location
GB
I have some ASP.Net pages with c# code behind them. After the user has made some selections the code goes off and does a lot of writing to a SQL database on another server. This can take a long time and although there's some text on the page saying that the user could be in for a long wait, the only feedback they get is their browser's progress bar.

Is there a way of either a) getting a page to refresh before a function ends so that I can use labels to indicate progress or b) implementing some sort of pop-up window that says "Working..."?

Nelviticus
 
If you look at a site like Expedia, they just use an animated gif.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I like the idea of just having an animation, but how do you get it to display?

The problem is that as soon as the user clicks the 'go' button, control passes to the c# code. I can do something like [tt]'imgWorking.Visible = [blue]true[/blue]'[/tt] but that won't take effect until the code has finished running, so the user won't see it until the processing has finished anyway.

Any idea how you make a page refresh while your code is running?

Nelviticus
 
With an animated gif, the user's browser animates it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Well I've tried two methods:

1) Have a hidden GIF on the same page as the 'go' button and set its 'visible' property to 'true' when the 'go' button is clicked. This doesn't work because the 'go' button also triggers the database updating, and the page isn't refreshed until this finishes.

2) Have the 'go' button redirect to a new page with a GIF, that triggers the database updating on the Page_Load event. This doesn't work either, because the page won't display until the Page_Load event - and the database updating - has finished.

Ah well. It's not the end of the world.

Nelviticus
 
Don't know if this will help Nelv, but I saw a post at 4Guys talking about re-wiring a back button. The code in the group of pages they talk about has code in ASP VBscript for displaying a message while the page does its background work. I imagine you can put some sort of animated gift or message there. If you translate it to C#, can you share it. :)

B
 
Why Not do a frame combo...

Frame 1 Has the anim running
Frame 2 Has autorefresh that polls the system for the status.
Frame 3 is doing the SQL.

While Frame three is working, it can write to a table in the DB as a log or status. Frame Two keeps polling on a refresh of 2 seconds and loads in the news status into itself. and the Frame One just looks pretty. You get the best all three worlds -- details about the event.. the event going and something animating while you wait..

When Frame 3 is done it can update the other tow frames with a completed Icon and the final status (errorlist too) and there you go.

-wolfgang
 
If this is a long process...I would think about passing the work off to something else. Have a middle tier do the database work...then redirect to a page to show your animated .gif. Set the auto-refresh, and check on each refresh if the processing is done. If it is...then direct the user to the correct page.
 
Thanks for all the replies, but I think that each of these is probably beyond my meagre abilities [sad]

I am fairly new to C#. I can do wonderful things with the stuff I already know but I have no idea what else it can do, which is why I asked whether there was a function to refresh an HTML page.

Worst of all my JavaScript knowledge is virtually zero. I have managed to get a pop-up window to appear containing an animated GIF but I can't get it to size properly, can't get it to be centred, can't disable the control buttons and don't know how to close it again! I guess I need to find a good 'JavaScript for idiots' book.

bjavierto, I had a look at the link you posted but couldn't really make their solution work for me.

wbochar, I like the sound of your idea but implementing it is beyond my skill unfortunately.

RiverGuy, again that's a bit beyond me. Although I'm working in an OO language I'm trained in procedural C, so I haven't got my head around multi-threading yet.

This issue is only a small problem and I'm not really experienced enough to do anything too complicated to fix it - this whole project has been a bit of a trial by fire for me, going from console-based C to a full-on ASP.Net/C#/database application. Fun, but a lot to learn in one go!

So thanks everyone but I think I'll just put up with what I have!

Nelviticus
 
Maybe this is over simplification, but can't you just do a simple onClick event that will change a blank image src to the animated image source, then add an onLoad event to switch the image back to blank?

<< azariah >>
 
This is probably a little beyond what you're asking here, but I was successfully able to create a real-time progress bar for file uploads. You can also apply this method to other processes once you have it figured out. Unfortunately, I can't post the code as it was done at work.

Combine these two posts to get you going on how I solved this problem:

I used some of the ideas in this code:
(thanks to dragonwell's post in my thread)

Combined with the overall idea in my post:

(The secret's all in using threading and the Thread.Sleep(int) method.)

Hope this gets some of you going on doing what most people say isn't possible on a webpage. :D

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top