JoshBerke JoshBerke - 1 year ago 81
ASP.NET (C#) Question

Please wait dialog & downloading files in

In my ASP.Net application I have a requirement that when a user clicks on an UI element we generate a PDF for them which they can download. This is currently implemented by doing a form post to an ashx page. This page essentially inspects the form and then executes the correct server side page which either results in HTML or a PDF document of that pages HTML.

On the client I know ahead of time if we are going to be getting a PDF or HTML, when its an HTML I open a new window and direct the form post to that window and all works well. When its a PDF I don't change the target for the form and it remains on the current page.

This works, the user is presented with a save dialog, and the current page is not changed or lost.

The problem I have is that generating the PDF takes anywhere from 1-15 seconds. What I want to do is popup a please wait dialog. Displaying the popup is going to be easy, what I am not sure of is how do I know to close the popup? The popup will be a div in the current page.

Answer Source

The popup can have a client side timer which polls the server for task completion. The long running server task should update the progress in a database table or a server cache object which can be accessed by the polling service.

Couple of old articles from MSDN magazine. You should be able to use the same concepts with newer libraries like Ajax.

Reporting Task Progress With ASP.NET 2.0

Simplify Task Progress with ASP.NET "Atlas"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download