By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,018 Members | 878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,018 IT Pros & Developers. It's quick & easy.

Save File Dialog

P: n/a
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
Mar 13 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
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

Mar 14 '06 #2

P: n/a
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=k...245&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
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
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


Mar 14 '06 #3

P: n/a
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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=k...245&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
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
> 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
>
>



Mar 14 '06 #4

P: n/a
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 = so**@address.com
.To = co************@domain.com
.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

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:un****************@TK2MSFTNGP10.phx.gbl...
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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=k...245&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
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
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!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jonny" <jo***@beagood.sod> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
> 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
>
>



Mar 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.