473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Save File Dialog

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
4 6225
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: cathywigzell | last post by:
I have a web page which allows a user to download a file directly to their computer, using IE. I present a file name in a table and the user can then right click on the file name to get a popup...
2
by: Alvo von Cossel I | last post by:
hi, i have a textbox in a form. when you press a Save button, a savefiledialog appears. creating ther file works but everytime you click save, the dialog appears. how do i make the dialog appear...
4
by: John | last post by:
Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download"...
4
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. ...
0
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response ...
1
by: M Pearson | last post by:
Hello there all, am very new to asp.net programming and am struggling with this problem. What I trying to achieve. On a button click I want the standard web save as dialog to display. The user...
3
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" +...
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.