隐藏模式窗口到Response.End()在asp.net中后 [英] Hide modal window after Response.End() in asp.net

查看:141
本文介绍了隐藏模式窗口到Response.End()在asp.net中后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮谁执行以下操作:

I have a button who does the following:

Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.csv");
Response.Charset = "";
Response.ContentType = "application/text";
//my content is created
Response.Output.Write(sb.ToString());
Response.Flush();
Response.End();

这是我的按钮定义:

<asp:Button ID="Button1" runat="server" onclick="Excel_Click" Text="Export to Csv" onclientclick="ShowModal();"/>

正如你可以看到我调用javascript函数,谁执行以下操作:

As you can see I call a javascript function, who does the following:

function ShowModal() {
        var divmodal = document.getElementById("divModal");

        divmodal.style.display = '';
    }

即。显示了与标签加载一个模式窗口
我的问题是当我下载我得到生成CSV文件,但我的模式窗口仍然出现之后,这是因为该页面不被刷新

i.e. shows a modal window with the label "Loading" My problem is when I download the file I get the csv generated but after that my modal window still appears, that's because the page isn't being refreshed

有什么我可以做什么?

在此先感谢

推荐答案

简短的回答是,你不能做到这一点。

The short answer is that you can not do that.

在您的文章回来的按钮,你是在等待新的内容加载页面。在这一刻,你没有任何控制从code后面,如当前页面的DOM给他们一个javascript code来执行。

After your post back with the button the page that you are is waiting a new content to load. At this moment you do not have any control to the current page dom from the code behind, eg send them a javascript code to execute.

即使你发送一个完整页面返回,那么它的一个新的完整的页面。

Even if you do send a full page back, then its a new full page.

您可以做一些其他的技巧,如使用一个处理程序来下载文件和链接,或使用Ajax来发送命令,并再次链接到一个处理器返回 - 但这样一来,一个完整的回发,你不能做到这一点。

You can make some other trick, eg use a handler to download the file and a link, or use ajax to send the command, and again return with a link to a handler - but that way, with a full post back, you can not do that.

这篇关于隐藏模式窗口到Response.End()在asp.net中后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆