Download file from ajaxified control (download dialog not appearing)

3 posts, 0 answers
  1. David
    David avatar
    16 posts
    Member since:
    Jan 2012

    Posted 13 Sep 2013 Link to this post

    I have several controls which were ajaxified using RadAjaxManager and I'm now trying to download a PDF. I understand 
    the issues with not being able to use Response.WriteFile (callbacks don't work...full postbacks do). I found 
    the following link on your site about using the ResponseScripts collection to get around this issue, i.e.,
      
      
    RadAjaxManager1.ResponseScripts.Add(String.Format(@"window.location.href = ""{0}"";", "http://yoursite.com/Your_File"));
      
    This works fine...but the file appears in the existing browser window...I do not get the file download dialog.
      
    Is there a way to add something similar to the following "content-disposition" header (with the attachment attribute)...so the download 
    file dialog appears?  I need the downloaded file to appear in a separate window.
      
    Response.AppendHeader("content-disposition", "attachment; filename = " + Path.GetFileName(fileName));
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Sep 2013 Link to this post

    Hello David,

    The required functionality could not be achieved when the Ajax techniques with registering ResponseScripts is used. I would suggest you to disable the Ajax for the specific download button in order to be able to append content-disposition header as needed.


    Regards,
    Maria Ilieva
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    16 posts
    Member since:
    Jan 2012

    Posted 18 Sep 2013 Link to this post

    Thanks Maria...I added,

    ajaxManager.set_enableAJAX(

     

    false);

     


    ...to the client-side function that triggers the download and it now works fine.
Back to Top