Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to close a window after downloaded/saved a file

Posted on 2005-03-03
6
Medium Priority
?
478 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
  • 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
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!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

572 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