?
Solved

How to close a window after downloaded/saved a file

Posted on 2005-03-03
6
Medium Priority
?
476 Views
Last Modified: 2012-06-21
Currently I have 3 pages:
Main.aspx – a page to let the user to choose report selection criteria, if the user click button “Print”, it will open a new window PleaseWait.aspx and pass the relevant selection criteria.
PleaseWait.aspx – a page only show a label “Report is being generated, please wait” and a progress bar gif, after the page is loaded for 3 seconds, it will redirect to Report.aspx and pass the releveant selection criteria.
Report.aspx – a page generates and shows the report according to the selection criteria, report format is either PDF or Excel (using Active Report).

It works fine if the report format is PDF as the PDF file will be redirected to show on the PleaseWait.aspx.
But if it is an excel format, the IE will automatically popup a dialog box asking if you want to “open”, ‘save”, or “cancel” the file. If you choose “save”, the PleaseWait.aspx will be still there and the “please wait…” message is still there after saved it?! It’s impossible to ask the user to open the Excel file instead of save it as there is no tool bar and save button on the top of the excel page…

My question is how do you know when the user choose “open” or “save” or “cancel” in this case? And how to you close the window if the user choose save?

Or, if there is any suggestion or solution to show the wait message while the report is generating and hide the message after report has been generated?
0
Comment
Question by:Koala119
[X]
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
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Expert Comment

by:Jesse Houwing
ID: 13456645
I'm sorry to say that you just don't know what the choice of the user was. You can't know when or if the user has saved the file to his/her system.

I guess it would be possible if you're using some kind of ActiveX control to handle the download, but other than that, there is nothing you can do about this.
0
 
LVL 4

Author Comment

by:Koala119
ID: 13457836
How to use ActiveX control? any example or sample codes?
0
 
LVL 3

Accepted Solution

by:
Jonthemoon earned 1400 total points
ID: 13458724
ToAoM is right.


I beleive this could be done if from your "pleasewait" page you first open the document (pdf or excel) in a new window then directly after, close the "pleasewait" window.

I did a little test and it works

<script language="javascript">
<!--

function Open(){
window.open("book1.xls","_blank")
window.close()
}
//-->
</script>

<input type="button" onclick=Open()>


It prompts for Open, Save Cancel and whatever you do, it closes the pleasewait page.

Hope I'm not way off!!

-JTM
0
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!

 
LVL 17

Assisted Solution

by:Jesse Houwing
Jesse Houwing earned 600 total points
ID: 13459184
That's a nice soluion.. .hadn't thought of that yet. I think this maya ctually work (except when the person choses Open, in which case Excel will be opened in the window, and directly after that the window will close... You will need to somehow check which location is loaded into that form before you chose to close it:

<script language="javascript">
<!--

function Open(){
window.open("book1.xls","_blank")
     if (window.location.href.indexOf("my.host.name")<0)
     {
          window.close()
     }
}
//-->
</script>

<input type="button" onclick=Open()>

I haven't tried, but I think it will do the trick...
0
 
LVL 3

Expert Comment

by:Jonthemoon
ID: 13460309
The pleasewait page will close but not the excel which is opened in the new window.


See it as

PleaseWait just open a new window then closes itself. The trick is that it won't close until the user click either the Save,Cancel or Open button.


-JTM
0
 
LVL 4

Author Comment

by:Koala119
ID: 13474147
Thanks for all of your suggestion, but it doesn't work in my side...
The problem is I am generating the excel/pdf in memory stream, I can't save it in hard disk and do the window.open("book1.xls","_blank").

I have found a way to show the menu bar even in excel. So, what I am going to do now is force the file to be opened in the browser, never show the dialog box. But I don't know why excel file always pop up the dialog box:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21340077.html
0

Featured Post

Technology Partners: 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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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