下载完后,给用户个提示
string name = @"c:\123.rar";
FileInfo aFile = new FileInfo(name);
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("123.rar", Encoding.UTF8));
Response.AddHeader("Content-Length", aFile.Length.ToString());
Response.WriteFile(name);
Response.Flush();
Response.End();
下载完后,想给用户一个提示框,提示下载成功
------解决方案--------------------try{
string name = @"c:\123.rar";
FileInfo aFile = new FileInfo(name);
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("123.rar", Encoding.UTF8));
Response.AddHeader("Content-Length", aFile.Length.ToString());
Response.WriteFile(name);
Response.Flush();
Response.End();
Response.Write("<script>alert('下载成功!');</script>");
}
catch{
Response.Write("<script>alert('下载失败!');</script>");
}
------解决方案--------------------在最后加上
Response.Write(" <script> alert('哈哈'); </script> ");
------解决方案--------------------RegisterClientScriptBlock("01","<script>alert('成功')</script>");
------解决方案--------------------Response.Write("<script>alert('下载完成!');</script>");
------解决方案--------------------C# code
Page.RegisterStartupScript("ALERT", <script language='javascript'>alert('DONE');</script>)