This is a migrated thread and some comments may be shown as answers.

RadWindow will not close when using Response.TransmitFile

2 Answers 68 Views
Window
This is a migrated thread and some comments may be shown as answers.
jlj30
Top achievements
Rank 2
jlj30 asked on 04 Dec 2012, 07:43 PM
Hi,

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 + "\"");
Response.TransmitFile(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");
                window.close();
            }
 
<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">
                <ContentTemplate>
                    <div style="padding: 5px;">
                        <telerik:RadButton ID="btnEx2PDF" OnClick="Export2PDF" CommandName="Export" Text="Export" OnClientClicked="closePDF();return false;"
                            runat="server">
                        </telerik:RadButton>
                        <telerik:RadButton ID="btnCancel" OnClick="Export2PDF" CommandName="Cancel" Text="Cancel"
                            CausesValidation="false" runat="server">
                        </telerik:RadButton>
                    </div>
...

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

Jim

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Dec 2012, 09:45 PM
Hello Jim,

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

Javascript:
function closePDF(sender, args){
...
}


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

I hope that helps.
0
jlj30
Top achievements
Rank 2
answered on 05 Dec 2012, 10:11 PM
Hi Kevin,

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

Jim
Tags
Window
Asked by
jlj30
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 2
jlj30
Top achievements
Rank 2
Share this question
or