【问题标题】:Closing a Window after Writing File to Response将文件写入响应后关闭窗口
【发布时间】:2013-05-15 13:53:02
【问题描述】:

我的窗口控制器有一些问题,单击保存按钮后,窗口应该关闭,但它没有。我不知道代码有什么问题。

Hier 是我的 C# 代码

protected void Save_btn_click(object sender, EventArgs e)
{  
    // Saving diagram. 
    string AppPath = Server.MapPath(string.Empty);
    DiagramWebControl1.SaveBinaryDocument(AppPath + "\\" + tbSaveFileName.Text);

    // Saving diagram locally.
    string filepath = AppPath + "\\" + tbSaveFileName.Text;
    HttpContext.Current.Response.ContentType = "application/octet-stream";
     HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;     
     filename=" +  tbSaveFileName.Text); 

    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.WriteFile(filepath);
    HttpContext.Current.Response.End();
}

ASPX 代码

   <syncfusion:Window ID="wndSafeFile" runat="server" Height="170px" Width="396px" DraggingStyle="Original"
                   Title="Speichern" clientobjectid ="_sfSaveFileWindow" IconImageUrl="../Images/KBD-Favicon.ico" ClientSideOnCloseUp="OnWindowClose()">
   <table id="Table1"  border="0" cellpadding="10" cellspacing="0" style="background-color:#f3f3f3;width: 390px" runat="server">
        <tr id="Tr1"  runat="server">
            <td id="Td1"  align="center" style="padding-top:10px;" valign="middle" runat="server">
            <asp:Label ID="Label"  runat="server" Text="File Name" Font-Name="Segoe UI" Font-Size="11"></asp:Label>&nbsp;
                <asp:TextBox id="tbSaveFileName" Text=".edd" runat="server" Font-Name="Segoe UI" Font-Size="11"
                     Height="20" Width="150"/>
            </td>
        </tr>
        <tr>
        <td id="Td2"    align="center"  style="padding-bottom:5px;padding-top:5px" runat="server">
        <asp:Button runat="server" ID="btnSave" OnClick="Save_btn_click" Font-Name="Segoe UI" Font-Size="11" Width="100px" Text="Save"  BackColor="#dfdfdf" BorderWidth="1" BorderColor="#dfdfdf" BorderStyle="Solid" Height="30px" />
        </td>
        </tr>
    </table>
</syncfusion:Window>

【问题讨论】:

    标签: response syncfusion


    【解决方案1】:

    您的要求可以通过在按钮的 OnClientClick 事件中使用 Close() 方法关闭窗口来实现。参考下面的代码sn-p,

      <syncfusion:Window ID="wndSafeFile" runat="server" InitiallyShown="true" Height="170px"
        Width="396px" DraggingStyle="Original" Title="Speichern" ClientObjectId="_sfSaveFileWindow">
        <table id="Table1" border="0" cellpadding="10" cellspacing="0" style="background-color: #f3f3f3;
            width: 390px" runat="server">
            <tr id="Tr1" runat="server">
                <td id="Td1" align="center" style="padding-top: 10px;" valign="middle" runat="server">
                    <asp:Label ID="Label" runat="server" Text="File Name" Font-Name="Segoe UI" Font-Size="11"></asp:Label>&nbsp;
                    <asp:TextBox ID="tbSaveFileName" Text=".edd" runat="server" Font-Name="Segoe UI"
                        Font-Size="11" Height="20" Width="150" />
                </td>
            </tr>
            <tr>
                <td id="Td2" align="center" style="padding-bottom: 5px; padding-top: 5px" runat="server">
                    <asp:Button runat="server" ID="btnSave" OnClick="Save_btn_click" Font-Name="Segoe UI"
                        Font-Size="11" Width="100px" Text="Save" BackColor="#dfdfdf" BorderWidth="1"
                        OnClientClick="click()" BorderColor="#dfdfdf" BorderStyle="Solid" Height="30px" />
                </td>
            </tr>
        </table>
      </syncfusion:Window>
    <script type="text/javascript">
        function click() {
             _sfSaveFileWindow.Close();
            return false;
        }
    </script>
    

    试试上面的建议

    【讨论】:

      猜你喜欢
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 2020-09-06
      • 2015-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多