RadWindow will not close when using Response.TransmitFile

3 posts, 0 answers
  1. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 04 Dec 2012 Link to this post


    I use RadWindow throughout my application.
    I typically close the window in code behind using winPDF.VisibleOnPageLoad = false; and this works just fine.
    However, if I'm using the following code to cause a file to be downloaded to the client, then the RadWindow remains open:

    Response.ContentType = "application/pdf";
    Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + fullfilename + "\"");
    winPDF.VisibleOnPageLoad = false; // Close the RadWindow

    Placing the last line above before the Response. statements has no effect.
    I have tried adding  OnClientClicked="closePDF();return false;" to the RadButton on the RadWindow that performs the export, but that results in an error since the function can't seem to find the window.  My idea was to cause the window to close and then the postback to occur to cause the above code behind to fire.  Here's the relevant code in my aspx page:

    function closePDF() {
                    var window = $find("ctl00_ContentPlaceHolder_winPDF");
    <telerik:RadWindow ID="winPDF" Width="300px" Height="240px" runat="server" Title="Export to PDF" Style="z-index: 999999"
                    VisibleOnPageLoad="false" Behaviors="Move" EnableShadow="true" Modal="true" OnClientClose="OnClientClose">
                        <div style="padding: 5px;">
                            <telerik:RadButton ID="btnEx2PDF" OnClick="Export2PDF" CommandName="Export" Text="Export" OnClientClicked="closePDF();return false;"
                            <telerik:RadButton ID="btnCancel" OnClick="Export2PDF" CommandName="Cancel" Text="Cancel"
                                CausesValidation="false" runat="server">

    When the application is run, the "window" variable in the above function is null.
    If I remove the OnClientClicked event from the RadButton, I get no errors, but the RadWindow will not close.

    Any ideas?

    Thanks in advance

  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 05 Dec 2012 Link to this post

    Hello Jim,

    The reason your OnClientClicked event fails is because it's not in the correct format. It should look like this:

    function closePDF(sender, args){

    <telerik:RadButton ID="btnEx2PDF" OnClick="Export2PDF" CommandName="Export" Text="Export" OnClientClicked="closePDF" runat="server">

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jlj30
    jlj30 avatar
    101 posts
    Member since:
    Jan 2011

    Posted 05 Dec 2012 Link to this post

    Hi Kevin,

    Thanks for your assistance.
    It's working fine now.

Back to Top