radwindow with download button

4 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 31 Jan 2012 Link to this post

    I have a RadWindow, has a download button, on the download button

    On download_click does below.

    Response.AddHeader("Content-Disposition", "attachment;filename=" + MyFileInfo.FullName);
      
    Response.WriteFile(FullPath, StartPos, FileSize);
      
    Response.End();

    Then pop up the window download screen, you can click save or open, if I click "save", it downloads file perfectly. If I click "Open", the file displays in the html parent window instead of the Radwindow. If there anyway that the "Open" displays html in the Radwindow instead of the parent window?

    Thanks!
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 01 Feb 2012 Link to this post

    Hello JJ,

    Are you using the ContentTemplate of the RadWindow? If so - this button is a part of the main page and this means that this behavior is correct. In case you are using the NavigateUrl to open a new page it should work as expected, as it has its own window object (it is loaded in an iframe) and its Response object is different than the parent page's. This means that it behaves like an iframe if an external page is loaded and like a regular Panel if the ContentTemplate is used. I hope this information will help you decide how you can proceed.

    I tried reptoducing this behavior, yet on my end things were working as expected: http://screencast.com/t/IDVC7bReEC. I am also attaching my test pages as a reference here. Please also note that how the browser opens a file largely depends on the user's settings and cannot always be controlled by the developer. You will notice that my browser, for example, opens a new tab.


    Greetings,
    Marin
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 01 Feb 2012 Link to this post

    Thanks for the example. I see what is the difference between your sample and mine. I used NavigateURL with Radwindow manager. If you use a text file with no extention instead of flower.gif in your attached example, you will see what I am talking about - the text file will displayed on the parent browser window.

     

  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 02 Feb 2012 Link to this post

    Hello JJ,

    I tried removing the file extension and, as expected, the browser did not know what the file was and therefore what to do with it: http://screencast.com/t/WBwmUo2GadAq. Once I returned it to .txt the default browser action was triggered (which, on my PC, is opening via Notepad).

    What I can suggest at this point is that you replace the RadWindow with a regular iframe, as this is what it is essentially. If you get the same behavior then this means that this is the way your browser works and this is not up to the developer to control but to the browser settings.

    Once you get the desired behavior with a simple iframe the same approach should work for the RadWindow as well. In case you get different behavior between a RadWindow and a regular iframe please open a support ticket and send us a runnable sample that shows this difference. You can use my pages as base - what is needed is that it is runnable and that it reliably reproduces the issue at hand.


    Kind regards,
    Marin
    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