“可见”是真的,但它不起作用

时间:2021-07-10 22:50:39

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.

默认情况下,“BackupSuccessfullyPnl”的“Visible”为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.

如果BackUpPlaceRBL.SelectedIndex == 1,我想下载创建的文件。

When BackUpPlaceRBL.SelectedIndex != 1, the "BackupSuccessfullyPnl" is shown perfectly. But when file is downloaded, panel is not visible. what is wrong?

当BackUpPlaceRBL.SelectedIndex!= 1时,“BackupSuccessfullyPnl”完美显示。但是下载文件时,面板不可见。哪里不对?

1 个解决方案

#1


1  

TransmitFile take full control of the response.

TransmitFile完全控制响应。

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.

因此,虽然您将True设置为控件的可见性,但输出响应实际上是一个下载的文件。这就是你没有看到变化的原因。

So what can I do?

那我该怎么办?

great.

大。

you create an iframe which hosts a page which has this code of downloading a file(only).

您创建一个iframe,它承载一个具有此代码下载文件的页面(仅限)。

and on your main screen(page) you can set the visible=true.

在主屏幕(页面)上,您可以设置visible = true。

#1


1  

TransmitFile take full control of the response.

TransmitFile完全控制响应。

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.

因此,虽然您将True设置为控件的可见性,但输出响应实际上是一个下载的文件。这就是你没有看到变化的原因。

So what can I do?

那我该怎么办?

great.

大。

you create an iframe which hosts a page which has this code of downloading a file(only).

您创建一个iframe,它承载一个具有此代码下载文件的页面(仅限)。

and on your main screen(page) you can set the visible=true.

在主屏幕(页面)上,您可以设置visible = true。