473,395 Members | 1,677 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,395 software developers and data experts.

Save or Open

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"
Hyperlink1.NavigateUrl = "MyReport.csv"

When the user clicks the HyperLink I would always like to
see the dialog come up that asks if you want to 'Open' the
file or 'Save' the file to disk.

I get mixed results. If the client has Excel installed
then this dialog does not come up and IE pops the file
into a spread sheet. If Excel is not installed then IE
pops the file up in a text window (same thing happens if I
delete the csv from the folder options).

If I change the file extension to something strange
like .xyz123 then it always comes up with the dialog but
I want the user to have the option to save the file as
csv.

Anyway, is there some way to force this to always come up
with the Open or Save dialog?

Tks,
JOhn
Nov 17 '05 #1
4 5065
Not that i know of. Users can force the dialog manually by right clicking /
Save Target As. Either that or just zip the file.
-Trevor
"John" <jc*******@dashgroup.com> wrote in message
news:01****************************@phx.gbl...
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"
Hyperlink1.NavigateUrl = "MyReport.csv"

When the user clicks the HyperLink I would always like to
see the dialog come up that asks if you want to 'Open' the
file or 'Save' the file to disk.

I get mixed results. If the client has Excel installed
then this dialog does not come up and IE pops the file
into a spread sheet. If Excel is not installed then IE
pops the file up in a text window (same thing happens if I
delete the csv from the folder options).

If I change the file extension to something strange
like .xyz123 then it always comes up with the dialog but
I want the user to have the option to save the file as
csv.

Anyway, is there some way to force this to always come up
with the Open or Save dialog?

Tks,
JOhn

Nov 17 '05 #2
Try creating an ASPX page that opens and reads the file, and then sets the
Response.ContentType property to "application/octet-stream" and then
Response.BinaryWrite()s the file to the output stream. Then you can link to
this file, and you should get the desired effect.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.

"John" <jc*******@dashgroup.com> wrote in message
news:01****************************@phx.gbl...
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"
Hyperlink1.NavigateUrl = "MyReport.csv"

When the user clicks the HyperLink I would always like to
see the dialog come up that asks if you want to 'Open' the
file or 'Save' the file to disk.

I get mixed results. If the client has Excel installed
then this dialog does not come up and IE pops the file
into a spread sheet. If Excel is not installed then IE
pops the file up in a text window (same thing happens if I
delete the csv from the folder options).

If I change the file extension to something strange
like .xyz123 then it always comes up with the dialog but
I want the user to have the option to save the file as
csv.

Anyway, is there some way to force this to always come up
with the Open or Save dialog?

Tks,
JOhn

Nov 17 '05 #3
Thanks, this seems to work. One small problem, when you
clict 'Open' it repeats the dialog and you need to click
Open a second time. But, much better than before.
-----Original Message-----
It is a tricky problem, most browsers try to do whatever they can dependingon the type of file.
However, it is possible to override the headers of the output to convincethe browser that it should try and do something else with it.
Instead of just a hyperlink url, generate a control (button / imagebuttonetc) with an event / postback
Then within the server side code (OnClick) use the following with theResponse object.

Response.AppendHeader( "content-disposition", "attachment;
filename=MyReport.csv");
Response.WriteFile(Server.MapPath ("MyReport.csv")); Response.End();

Regards,
Robin

"John" <jc*******@dashgroup.com> wrote in message
news:01****************************@phx.gbl...
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"
Hyperlink1.NavigateUrl = "MyReport.csv"

When the user clicks the HyperLink I would always like to see the dialog come up that asks if you want to 'Open' the file or 'Save' the file to disk.

I get mixed results. If the client has Excel installed
then this dialog does not come up and IE pops the file
into a spread sheet. If Excel is not installed then IE
pops the file up in a text window (same thing happens if I delete the csv from the folder options).

If I change the file extension to something strange
like .xyz123 then it always comes up with the dialog but I want the user to have the option to save the file as
csv.

Anyway, is there some way to force this to always come up with the Open or Save dialog?

Tks,
JOhn

.

Nov 17 '05 #4
Sorry about blank reply!! Ack, itchy fingers!

Strange, check that there are no other Response Redirects or Url links as
part of this control. Also, maybe try clearing the Response object before
adding the new header and writing the file.

In general whenever I find I need to force the use to do a save as (as
below) I usually provide two buttons, one for save, one for open. The save
forces the dialog and the open just does a response.redirect. That way they
never have the need to click the Save button and then try and open it.

"john" <jc*******@dashgroup.com> wrote in message
news:0c****************************@phx.gbl...
Thanks, this seems to work. One small problem, when you
clict 'Open' it repeats the dialog and you need to click
Open a second time. But, much better than before.
-----Original Message-----
It is a tricky problem, most browsers try to do whatever

they can depending
on the type of file.
However, it is possible to override the headers of the

output to convince
the browser that it should try and do something else with

it.

Instead of just a hyperlink url, generate a control

(button / imagebutton
etc) with an event / postback
Then within the server side code (OnClick) use the

following with the
Response object.

Response.AppendHeader( "content-disposition", "attachment;
filename=MyReport.csv");
Response.WriteFile(Server.MapPath

("MyReport.csv"));
Response.End();

Regards,
Robin

"John" <jc*******@dashgroup.com> wrote in message
news:01****************************@phx.gbl...
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"
Hyperlink1.NavigateUrl = "MyReport.csv"

When the user clicks the HyperLink I would always like to see the dialog come up that asks if you want to 'Open' the file or 'Save' the file to disk.

I get mixed results. If the client has Excel installed
then this dialog does not come up and IE pops the file
into a spread sheet. If Excel is not installed then IE
pops the file up in a text window (same thing happens if I delete the csv from the folder options).

If I change the file extension to something strange
like .xyz123 then it always comes up with the dialog but I want the user to have the option to save the file as
csv.

Anyway, is there some way to force this to always come up with the Open or Save dialog?

Tks,
JOhn

.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
3
by: Newbie | last post by:
I am trying to get the save/open dialog figured out. I am able open the save dialog but when I put in a file name (whatever.txt) and save the file does save with the name but it is blank. Below...
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...
6
by: Mike | last post by:
can i open the save file dialog box from a asp.net web page? thx
4
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the...
5
by: Patrick | last post by:
Following on from the excellent example at http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp on how to save a data-grid to excel file, how can I extend the example such...
6
by: Michael Groeger | last post by:
Hi, I have an aspx page which generates an excel document and transfers it to the browser as attachment. Normally, once the document is transferred the open save dialog prompts to open or save...
1
by: Rameel | last post by:
Friends, I'm probably being more critical with VB.Net Windows application. I have Developed VisualStudio 20005 VB.Net Windows application how willl i be able to save a specific record into my...
14
by: squrel | last post by:
Hello everyone, I m using some button using toolbar such as Add,Save,View,.... my save button is not working.... it doesnt give me any error but does not save to my database.... or showing in my...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.