保存对话框将文件保存到本地计算机.但在那之后,我的页面就站在那里,对我的剩余工作没有任何作用.我使用下面的代码打开一个保存对话框
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();
}
}
Run Code Online (Sandbox Code Playgroud)
HTML代码是:
<asp:Button id="lnkbtnDownload" runat="server" CausesValidation="false"
Text="Download" CssClass="buttonstyle" OnClick="lnkbtnDownload_Click"></asp:Button>
Run Code Online (Sandbox Code Playgroud)
但是在将文件保存到本地计算机并且保存对话框关闭后,我的页面根本没有响应.保存对话框关闭后,我可以知道如何回页.
| 归档时间: |
|
| 查看次数: |
3442 次 |
| 最近记录: |