G
Guest
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.
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.