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!
 
J

Jonny

Hello Nathan

Thank you once again for your reply.

I do not wish for the user to send a file to the server, but to be able to
use an Open or Save File Dialog to choose a file (JPG or BMP) to e-mail a
certain address

There is a form which the use fills in to report any computer or printer
problems. Maybe the user has done a screen dump of an error message too. I
want for that file to be chosen by the user which then gets added to a
certian address:

Example (typed straight in here):

Dim mes As New System.Web.Mail.Message
Dim mesAttachment As ...MessageAttachment
With mes
.From = (e-mail address removed)
.To = (e-mail address removed)
.Subject = cboFault.Text

Pseudo

If Not mesAttachment <> Nothing Then
mesAttachment = New MessageAttachment (mesAttachment[Filename
Here].[Extension Here])
End If
End With

SmtpMail.Send(mes)

-----------------------------------------

The way you describe regarding the radio buttons isn't a good idea because
the users (school teachers) won't bother setting them & then they will just
call the office when I need it logged like above. Therefore I need that
OpenFileDialog for the teachers to use & to be able to select an screen dump
if they have one...

If I upload the file to the server then there could be a particular user
calling a simular screen dump the same name as one listed on the server then
it will be overwritten.

In the document (see KB link) they do what you have shown me, but I need
that chosen file e-mailed & not uploaded to the server. If the users
(teachers) haven't chosen a file (screen dump) then to send the e-mail
anyway without the requirement of an attachment.

I hope this have cleared up what I need. If not, I will knock up a Windows
application that does exactly what I want & paste the whole form class code
here for you to replicate. Then you will see what I need in a web based
page.

Thank you once again for your reply

Regards,

Jonny
 

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

Top