这是我的代码:
string result = BackUp.BackupDatabase(folder, fileName);
if (result == "Complete")
{
BackupSuccessfullyLbl.Text = "BackUp created successfully.";
BackupSuccessfullyPnl.Visible = true;
if (BackUpPlaceRBL.SelectedIndex == 1)
{
var file = new System.IO.FileInfo(folder + fileName);
Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AppendHeader("Content-Length", file.Length.ToString());
Response.TransmitFile(file.FullName);
}
}
默认情况下,"BackupSuccessfullyPnl
"的"可见"为false。
我已经从数据库创建了一个备份,然后我显示了成功的消息。
我想下载创建的文件if BackUpPlaceRBL.SelectedIndex == 1.
当BackUpPlaceRBL.SelectedIndex != 1
时,"BackupSuccessfullyPnl
"会完美显示。但当文件被下载时,面板是不可见的。怎么了?
TransmitFile
完全控制响应。
因此,尽管您将True设置为控件的可见性,但输出响应实际上是一个下载的文件。这就是为什么你看不到变化。
那么我该怎么办呢?
太好了。
您创建了一个iframe,它承载了一个页面,该页面包含下载文件的代码(仅限)。
在主屏幕(页面)上,您可以设置visible=true。