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

Download file from ajaxified control (download dialog not appearing)

2 Answers 53 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 13 Sep 2013, 08:11 PM
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 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Sep 2013, 09:03 AM
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.
0
David
Top achievements
Rank 1
answered on 18 Sep 2013, 05:01 PM
Thanks Maria...I added,

ajaxManager.set_enableAJAX(

 

false);

 


...to the client-side function that triggers the download and it now works fine.
Tags
Ajax
Asked by
David
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
David
Top achievements
Rank 1
Share this question
or