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

save as dialog

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.