Code Behind
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=sample.xls");
Response.Write("Hello World");
Response.End();
}
HTML Page
To disable Save button, write this meta tag
<head runat="server">
<meta name="DownloadOptions" content="nosave" />
</head>
To disable Open button, write this meta tag
<head runat="server">
<meta name="DownloadOptions" content="noopen" />
</head>
The Response.End has end the response, if i click again the button, this is no post back at all.
ReplyDeleteit didnt worked for me
ReplyDeleteNOT WORKING !!!!
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeletevfdcdcd not working
ReplyDelete