Johan
Johan

Reputation: 35213

Remove the "open" button in save file dialog (IE only)

I use the following code to generate a save file dialog:

Response.AppendHeader("content-disposition", "attachment; filename=" + name);
Response.WriteFile(Server.MapPath("~/test.html"), true);
Response.End();

Works as intended. However, I would like to remove the "open" button, so I just get the "save as" and "cancel". Is there any way to generate another kind of dialog?

Upvotes: 0

Views: 1435

Answers (3)

Alex KeySmith
Alex KeySmith

Reputation: 17101

There is a new way to do this using the "download" attribute on an which when a blank value will simply trigger the download. This however does not work in IE. But it could be used in conjunction with the meta tag.

Upvotes: 0

Johan
Johan

Reputation: 35213

Found the answer myself:

<META name="DownloadOptions" content="noopen"/>

Upvotes: 2

ThiefMaster
ThiefMaster

Reputation: 318568

That's not possible (in a cross-browser way) and this is a good thing.
It's solely the user's decision if the file should be saved in a folder he specifies or in the temporary folder of the system (and then be opened automatically).

However, for HTML files I see your point...

Upvotes: 2

Related Questions