save dialog saves file to the local machine. But after that, my page stand there and do nothing for the rest of my process. I use below code to open a save dialog
protected void lnkbtnDownload_Click(object sender, EventArgs e)
{
string fileName = startupPath + "bin\\Inbox.mdb";
System.IO.FileInfo targetFile = new System.IO.FileInfo(fileName);
if (targetFile.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name);
Response.AddHeader("Content-Length", targetFile.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(targetFile.FullName);
Response.End();
}
}
the html code is :
<asp:Button id="lnkbtnDownload" runat="server" CausesValidation="false"
Text="Download" CssClass="buttonstyle" OnClick="lnkbtnDownload_Click"></asp:Button>
but after the file is save to local machine and the save dialog is close, my page no response at all. May I know how to do a postback to the page after the save dialog is close.?
Because you are calling Response.End, this halts the response of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With