Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 April 14th, 2004, 09:36 AM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating and Downloading Text File

Hi,

     Is it possible to create a text file dynamically and save it to the client's computer using asp.net? I cannot create the text file in the web server. The file should be saved to the client computer directly.

The requirement for me is, when I click on a button, i should be able to create a text file and write certain details into it and save it to the client computer. Is there any way to do it.?

thanks and regards,
  Seby
 
Old April 14th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I think you can depending on certain circumstances, as long as the ASPNET account would have access to that folder. It may have to be in-network, but I'm not sure.

Also, would cookies be a viable solution for you?

Brian
 
Old April 14th, 2004, 11:08 PM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

   Thanks for the reply. I think I missed one point. When the user click on the button, the 'Save AS' dialog box will be open for the user and he can save the text file into his computer.
One more query I have is, how do I show the 'Save As' dialog box without asking for 'Open', 'Save' or 'Cancel' dialog box. That is, when the user click on the button, he should see only 'Save As' dialog box where he can save the text file to his computer.

Thanks and regards,
   Seby
 
Old April 14th, 2004, 11:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

its not in ur hand & is a browser facility, but I guess u could contol it! the dont set the href of ur <a> directly to file! make an onclick event & do some programming & when it click [u]Yes</u> or then call the file bc its not a web file im mean not (.asp, .aspx, htm, html, xml & ...) browser will go to download it!

HTH.

Always:),
Hovik Melkomian.
 
Old April 15th, 2004, 07:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

There is a file download box that you could use to specify the folder to save to, in the VS.NET designer, or if you aren't using VS.NET, it's <input type="file">.
 
Old April 16th, 2004, 02:45 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

seby,

There are two key points to solving this problem:
1) You need to create an ASPX page that outputs what you want for the file (nothing more). Then at some point you redirect to this page.
2) The page that outputs the "file" has to set content disposition. This tells the browser how to handle the content stream. You do this with the AddHeader method of the Response object:

Response.AddHeader("Content-Disposition", "attachment; filename=thefilename.ext")

This tells the browser two things: download the file, instead of showing it in the browser (if it can) and also what the file name is. You can change attachment to inline and the browser will attempt to open the file if it knows how.

Peter
-------------------------
Work smarter, not harder
 
Old April 17th, 2004, 12:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I dont thin so, since I know its for UPLOADING & not for downlod! can u tell how u r going to download with that!

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Text file in Mozilla Israr Java Basics 1 May 17th, 2007 06:34 AM
Text File not Creating! =( slim182 C# 2005 0 March 22nd, 2007 04:41 PM
Flash file downloading Adam H-W Flash (all versions) 1 December 15th, 2006 11:36 PM
Downloading a File RobC ASP.NET 2.0 Basics 4 February 4th, 2006 09:37 PM
Downloading Excel File [email protected] VB How-To 0 October 28th, 2004 11:40 AM





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