Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jQuery对话框没有';t在响应后从代码隐藏关闭。TransmitFile_C#_Jquery_Asp.net_Dialog_Download - Fatal编程技术网

C# jQuery对话框没有';t在响应后从代码隐藏关闭。TransmitFile

C# jQuery对话框没有';t在响应后从代码隐藏关闭。TransmitFile,c#,jquery,asp.net,dialog,download,C#,Jquery,Asp.net,Dialog,Download,我的问题是,当我从对话框后面的代码调用关闭对话框时,使用引用的aspx页面不会关闭。 如果我对代码的响应传输文件部分进行注释,则对话框将正确关闭,否则下载将开始,但对话框将保持打开状态。 如果你有什么建议,请告诉我,谢谢 ASPX页面: <%@ Page Async="true" AsyncTimeout="30" Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"

我的问题是,当我从对话框后面的代码调用关闭对话框时,使用引用的aspx页面不会关闭。 如果我对代码的响应传输文件部分进行注释,则对话框将正确关闭,否则下载将开始,但对话框将保持打开状态。 如果你有什么建议,请告诉我,谢谢

ASPX页面:

<%@ Page Async="true" AsyncTimeout="30" Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register src="CreateUI.ascx" tagname="CreateUI" tagprefix="uc1" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <%--JQuery--%>

    <script src="Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>

    <link href="Styles/jquery-ui-1.10.4.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function () {
            $('#jobDone').dialog({
                autoOpen: false,
                draggable: true,
                title: "Job completed",
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });
        });

        function showDialog(id) {
            $(function () {
                $('#' + id).dialog("open");
                return false;
            });
        }

        function closeDialog(id) {
            $(function () {
                $('#' + id).dialog("close");
                return false;
            });
        }
    </script>
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <!-- ScriptManager to manage UpdatePanel -->
    <asp:ScriptManager ID="mainScriptManager" runat="server"></asp:ScriptManager>

    <!-- CreateUI Component -->
    <uc1:CreateUI ID="CreateUIForm" runat="server" />

    <!-- Hidden Field to pass data -->
    <asp:Table ID="TableMain" runat="server" CssClass="table">
        <asp:TableRow ID="TableRow1" runat="server">
            <asp:TableCell ID="TableCell1" runat="server">
                <asp:HiddenField ID="UI_Paths" runat="server" />
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>

    <!-- div linked to Jquery dialog -->
    <div id='jobDone'>
        <asp:UpdatePanel ID="UpdatePanelDownload" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server">
            <ContentTemplate>
                <asp:Label ID="LabelMessage" runat="server" Text="Operation ended successfully, do you want to download the produced files?</br></br>"></asp:Label>
                <asp:Button ID="ButtonDownload" runat="server" Text="Yes" Width="50px" onclick="ButtonDownload_Click" />
                <asp:Button ID="ButtonNo" runat="server" Text="No" Width="50px" OnClientClick="closeDialog('jobDone'); return false;" />
            </ContentTemplate>
        </asp:UpdatePanel>            
    </div>        

</asp:Content>

我自己找到了解决办法。 问题在于,Response.End();在执行被抵制的javascrip in ButtonDownload\u单击之前结束响应

我尝试了建议的解决方案(在其他类似的线程中阅读),将Response.End()更改为context.ApplicationInstance.CompleteRequest(),但下载不是这样开始的

所以我删除了:

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), UniqueID, "closeDialog('jobDone');", true);
从ButtonDownload\单击,我修改了aspx页面:

<asp:Button ID="ButtonDownload" runat="server" Text="Yes" Width="50px" onclick="ButtonDownload_Click" />

为此:

<asp:Button ID="ButtonDownload" runat="server" Text="Yes" Width="50px" OnClientClick="closeDialog('jobDone');" onclick="ButtonDownload_Click" />

这样,ButtonDownload会突然从javascript关闭对话框,然后执行服务器端的ButtonDownload\u单击执行下载

<asp:Button ID="ButtonDownload" runat="server" Text="Yes" Width="50px" OnClientClick="closeDialog('jobDone');" onclick="ButtonDownload_Click" />