Reputation: 25
This is my code:
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);
}
}
By default "Visible" of "BackupSuccessfullyPnl
" is false.
I have created a back-up from my db, then I have showed the successfull message.
I want to download the created file, if BackUpPlaceRBL.SelectedIndex == 1.
When BackUpPlaceRBL.SelectedIndex != 1
, the "BackupSuccessfullyPnl
" is shown perfectly. But when file is downloaded, panel is not visible. what is wrong?
Upvotes: 1
Views: 96
Reputation: 148524
TransmitFile
take full control of the response.
so although you set True to visibility of the control , the output response is actually a file which is downloaded. that's why you dont see the changes.
So what can I do?
great.
you create an iframe which hosts a page which has this code of downloading a file(only).
and on your main screen(page) you can set the visible=true.
Upvotes: 1