Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2007, 10:53 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default File Download Window Problem

I have a site where a user can select a document and then click Download. So I do a window.open() to a page that calls a web service, I get back the file as a Stream from a Dime attachment and I write it to the Response.OutputStream. This works, but I still have a little blank window open from my original window.open() command. What's the best way to get rid of the little blank window the window.open() produces?
 
Old May 14th, 2007, 11:29 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Trigger the webservice download from the click event of (I am assuming) the button the user clicks to download the file.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 14th, 2007, 12:04 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not quite sure what you mean. I trigger the window.open() from the onclick event. How else would I trigger the web service download onclick? The web service just sends a Dime attachment to the caller. Do you mean to somehow call the web service directly from javascript on the client?
 
Old May 14th, 2007, 12:10 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your posting this question in an ASP.NET forum so, I assume, you are using .NET Web Forms; is that correct or are you using straight X/HTML

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 14th, 2007, 12:29 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I am using C# ASP.Net 1.1. Maybe my whole methodology is wrong. This is my first file download window.

The user selects an item in a Datagrid and then clicks a "Download" function. I then do a window.open() and pass the id of the document to be downloaded in the querystring. I then call a web service from the newly opened window's server-side C# code and get the document back as a Dime attachment. I then set the Response.ContentType and write the file stream into the OutputResponse stream. The file download works, but the window from the window.open() is still there.
 
Old May 14th, 2007, 12:38 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You don't need to open a window to start a file download, simply pushing the data down through the response stream will cause the Download dialog box to open. So, in your click event handler of your button, instead of calling window.open() call the logic that you are using in the file download window. This should work equally as well.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 14th, 2007, 01:07 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. I knew I was making it harder than it needed to be. What confused me was that I thought channeling the file through the output stream would overwrite the normal HTML in the stream that gets written to the client. I probably don't understand the lifecycle of the output stream well enough. Anyway, thanks.
 
Old March 8th, 2009, 08:31 PM
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Quote:
Originally Posted by AgentSmith View Post
What confused me was that I thought channeling the file through the output stream would overwrite the normal HTML in the stream that gets written to the client.
The page is not resent, so really there is nothing to be overwritten here. The response contains nothing but the downloaded file.




Similar Threads
Thread Thread Starter Forum Replies Last Post
File Download. rupen ASP.NET 1.x and 2.0 Application Design 4 February 23rd, 2008 08:43 AM
File Download Problem with AspSmartUpload componen mlbrv Classic ASP Components 0 December 4th, 2006 06:48 AM
Smaller download/single download file available jminatel BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 November 21st, 2005 11:10 AM
download dialog problem in modal window jaisonkmathews Javascript 2 February 11th, 2005 08:57 AM
File download problem sandeep_chalke .NET Web Services 0 June 24th, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.