We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Closing a Syncfusion Window Controller after Writing File to Response

Thread ID:

Created:

Updated:

Platform:

Replies:

108856 May 15,2013 10:48 AM May 22,2013 06:56 AM ASP.NET Web Forms (Classic) 3
loading
Tags: DiagramWebControl
Hayssam Hassan
Asked On May 15, 2013 10:48 AM

Hi there,

i have some problems with my window-controller, after clicking the save button the window should close, but it doesnt. i dont know whats is wrong with code.

Hier is my C# code:

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 Code:
<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>  <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>


Amsath Ali M [Syncfusion]
Replied On May 20, 2013 09:03 AM

Hi Rtoulait,

 

Thanks for your interest in Syncfusion products.

 

We are glad to inform you that we have achieved your requirement in the below attached sample and the same can be downloaded from the below link.

 

Here is the code:

[C#]

 

Deafult.Aspx.cs:

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;

            this.Page.RegisterClientScriptBlock("MyScript", "<script language=javascript> window.open('Download.aspx?path=" + tbSaveFileName.Text + "&Extension=" + ".edd" + "')</script>");

            wndSafeFile.InitiallyShown = false;           

        }

 

        protected void btnSave_Click(object sender, EventArgs e)

        {

            wndSafeFile.InitiallyShown = true;      

        }

 

Download.aspx.cs:

protected void Page_Load(object sender, EventArgs e)

    {

        string path = Request.QueryString["path"];

        string ext = Request.QueryString["Extension"].Replace('.',' ');

        Response.ContentType = "application/"+ ext;

        Response.AppendHeader("Content-Disposition", "attachment; filename="+path);

        Response.Clear();

        Response.TransmitFile(Server.MapPath(path));

        Response.End();

    }

Please try the below attached sample and let us know if you have any queries.

 

Regards,

Amsath Ali. M



F107637_f6d4f491.zip

Hayssam Hassan
Replied On May 21, 2013 06:40 AM

hi Amsath Ali. M,
thanks for your update. its working well.

Best regards,
Hayssam

Amsath Ali M [Syncfusion]
Replied On May 22, 2013 06:56 AM

Hi Hayssam,

 

Thanks for your update.

 

We are happy to hear that the issue has been resolved. Please let us know if you require any further assistance on this, we would be happy to help you out.

 

Regards,

Amsath Ali. M


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;