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

save as dialog

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=" +
HttpUtility.UrlEncode("あいうえお") + ".csv");
Encoding encoding = Encoding.GetEncoding("Shift-JIS");
Response.BinaryWrite(encoding.GetBytes(csvStr));
Response.End();

It works fine..the data gets saved nicely to an excel file. The user pushes
the button to download the file and then a dialog box pops up that asks if
they want to save or cancel. If the user presses the save, another dialog
box pops up where the user can change the name of the file and choose where
to save the file. The problem is that I have been told not to have two
dialog boxes pop up. When the user pushes the download button, how do I make
only the second dialog box come out? I tried

Response.Write("<script
type='text/javascript'>document.execCommand('SaveAs',null,' いうえお.csv');</script>");

but the webpage just gets saved to excel (not the csv file). I was told
maybe I can write some code to click the save(on the first dialog box that
pops up that asks if the want to save) so that only the second dialog comes
out(the one where the user can choose the name and location to save the file)
but I haven't figured it out. Any ideas? Please help me.

Jan 19 '07 #1
3 6405
hi,
if the user clicks save, then they must also provide the location to save
it, this is a browser feature that you can't control (to my knowledge). i
personally am glad that it is not possible to manipulate the 'save' dialog
box. otherwise there would be a risk of a web site trawling your file
system without you knowing it.

i would say your best option is to open the document inline instead of
'attachment', and then if the user wants to save it they can use the
toolbars / menus etc to do that. then they will only get one dialog box.

most browsers have an option to 'always do this for this file type' in the
'open or save' dialog box. your users can tick the box if they don't want
to be asked again. it sounds like the boss has given an unreasonable
requirement based on a very shallow understanding of usability. this is the
way browsers work, it is what people are familiar with.

tim


"asdf" <as**@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...
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=" +
HttpUtility.UrlEncode("あいうえお") + ".csv");
Encoding encoding = Encoding.GetEncoding("Shift-JIS");
Response.BinaryWrite(encoding.GetBytes(csvStr));
Response.End();

It works fine..the data gets saved nicely to an excel file. The user
pushes
the button to download the file and then a dialog box pops up that asks if
they want to save or cancel. If the user presses the save, another dialog
box pops up where the user can change the name of the file and choose
where
to save the file. The problem is that I have been told not to have two
dialog boxes pop up. When the user pushes the download button, how do I
make
only the second dialog box come out? I tried

Response.Write("<script
type='text/javascript'>document.execCommand('SaveAs',null,' いうえお.csv');</script>");

but the webpage just gets saved to excel (not the csv file). I was told
maybe I can write some code to click the save(on the first dialog box that
pops up that asks if the want to save) so that only the second dialog
comes
out(the one where the user can choose the name and location to save the
file)
but I haven't figured it out. Any ideas? Please help me.
Jan 19 '07 #2
because you have specified 'attachment' in the http header, the browser will
always prompt the user asking if they want to open or save. unless of
course they have specified a default action for the file type (browser
feature over which you have no control).

good luck
tim

"asdf" <as**@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Sorry if what I'm trying to ask was unclear. I don't want to stop the
"save
as" dialog box. I want to stop or click through the security dialog box
that
pops up before. I think it comes up depending on the IE setting, but the
customer only wants the save as dialog to come up when their employees
click
the download button. Any ideas or suggestions? Is it impossible?
Jan 20 '07 #3
Thank You very much. I really appreciate your help.

"Tim Mackey" wrote:
because you have specified 'attachment' in the http header, the browser will
always prompt the user asking if they want to open or save. unless of
course they have specified a default action for the file type (browser
feature over which you have no control).

good luck
tim

"asdf" <as**@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Sorry if what I'm trying to ask was unclear. I don't want to stop the
"save
as" dialog box. I want to stop or click through the security dialog box
that
pops up before. I think it comes up depending on the IE setting, but the
customer only wants the save as dialog to come up when their employees
click
the download button. Any ideas or suggestions? Is it impossible?
Jan 22 '07 #4

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

Similar topics

7
by: joseph.inglis | last post by:
I have a web browser object on a form which I have set to edit mode and use the UCOMIConnectionPointContainer interface to hook in and catch events. All working sweetly. Except there...
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...
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...
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...
8
by: paquer | last post by:
I'd like to provide an Export Function from my forms, where the User can choose the File name & save location Although I cannot get the "Save As" dialog box to open properly from access. What is...
0
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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.