Save File Dialog

J

Jonny

Hello Group

How do I open a Save File Dialog from an ASPX page behind a browse button?

Any help would be fantastic!!

I am using ASP.NET 1.1 using VB.NET as the coding language

TIA
 
N

Nathan Sokalski

Here is some sample code that will download a text file named download.txt
with some text and the date/time appended to the end. To download another
file type you would do the same thing, just change the Response.ContentType
and Response.WriteFile lines, and possibly add or remove any Response.Write
or Response.WriteFile lines. One thing that you can also do is not save the
file at all, and just use a bunch of Response.Write lines to dynamically
create something like a tab delimited data file or a schedule or reciept or
whatever, using only Response.Write saves you the trouble of saving a
temporary file every time someone downloads something unique to their
situation. I think you probably have the basic idea, if you have any
problems, let me know.


Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDownload.Click
Response.ClearContent()
Response.ContentType = "text/plain"
Response.AddHeader("content-disposition",
"attachment;filename=download.txt")
Response.WriteFile(Server.MapPath("download.txt"))
Response.Write("This is a test download text file" & ControlChars.NewLine)
Response.Write(Date.Now.ToLongDateString() & " " &
Date.Now.ToLongTimeString())
Response.End()
End Sub


Good Luck!
 
J

Jonny

Thank you for your suggestion, but I would like the user to be able to pick
either a BMP or JPG file via an Open File Dialog or Save File Dialog & that
file then becomes the attachment of the e-mail

There is a KB article
(http://support.microsoft.com/?scid=kb;en-us;323245&spid=6245&sid=global
) which opens a file of the user's choice, but it then sends that file to
the server rather than being able to attach it to an e-mail. I need to be
able to attach it as an e-mail attachment, not upload it

I hope you understand
 
N

Nathan Sokalski

I am a little confused about what you are looking to do. The code I sent you
lets the user download the file from the server to their computer. If you
are looking to upload a file from the client to the server, use a
System.Web.UI.HtmlControls.HtmlInputFile control (I can show you the code to
upload a file using this control if you want). If you want to give the user
the choice between a .bmp and a .jpeg, simply create either two buttons that
they can click or use some extra control(s) such as a DropDownList or
RadioButton so that they can specify which one they want. If you are trying
to let the user attach a file to an email that will be sent from the server,
use the System.Web.Mail.MailMessage class. If you would like any help doing
any of these things, or if you are trying to do something that I am missing,
provide any details you can so that me or anyone else who reads your message
can do their best to help. Good Luck!
 
Joined
Nov 21, 2009
Messages
1
Reaction score
0
there any way to track, whether user has actually downloaded file, or user has cancel

Hi all...

need some help.. , we can download the file using response object as shown above, but is there any way to track, whether user has actually downloaded file, or user has cancelled file..

any help on this will be apreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top