Closing a radwindow which has generated a non-HTML content to response stream

2 posts, 0 answers
  1. Deepak Vasudevan
    Deepak Vasudevan avatar
    82 posts
    Member since:
    May 2010

    Posted 01 Jun 2012 Link to this post

    I have a page and clicking of a button opens a small RadWindow. Here the user makes some selections and clicks 'Generate' button. Now the server will start to stream a PDF file. Now radWindow.VisibleOnPageLoad = false does not work because the response stream is now PDF and not normal content type text/html

    Is there a way to close the RadWindow in this case or is it a bug/limitation with Telerik RadWindow? 
  2. Marin Bratanov
    Marin Bratanov avatar
    5705 posts

    Posted 05 Jun 2012 Link to this post

    Hello Deepak,

    This is neither a bug, nor a limitation of the control, but the general way things work when you change the response stream. You can no longer inject a JavaScript function from the code-behind of the page loaded in the RadWindow to close it because you no longer have a page inside. What you have is the browser's PDF plugin in case it is configured to show the pdf in place. The only way to go around this would be to store the pdf file on the server as a file, save a link to it and while you still have the page loaded inject a script instead of change the reponse. The script will 1) close the RadWIndow and 2) navigate the page to the URL passed from the server. Once the RadWIndow is closed it will not be visible yet its iframe is still active on the page (unless you have the DestroyOnClose property set to true, in this case you will get an error). Note that in this way how the user sees things depends on their machine - if it is configured to show the pdf inline and not show a download/save as box the user will not see the pdf at all. This is also the case with a browser popup. If you are capable of calling a script that will close a browser popup after you've shown a pdf inside the same logic can be used to close the RadWindow.

    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top