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

Download file in AJAX page

3 Answers 551 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kosal
Top achievements
Rank 1
Kosal asked on 26 Aug 2008, 05:10 PM
I'm trying to add the ability to download a file by clicking on a link that is in a RadGrid within a RadAjaxPanel.  I'm using Response but realize that doesn't work with Ajaxified pages.  Are there any workarounds for this snippet of code?

if (dlFile.Exists)

{

Response.ClearContent();

Response.AddHeader("Content-Disposition", "attachment; filename=" + dlFile.Name);

Response.AddHeader(

"Content-Length", dlFile.Length.ToString());

Response.ContentType = ReturnExtension(dlFile.Extension.ToLower());

Response.TransmitFile(dlFile.FullName);

Response.End();

}



Thanks

3 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 27 Aug 2008, 05:32 AM
Hi Kosal,

The link should perform postback to be able to download the file, which operation is generally restricted in AJAX scenario. You can either try the ResponseScripts work-around explained in the documentation here, or implement partial postback for the link in question as demonstrated on this demo:

http://demos.telerik.com/aspnet/prometheus/Ajax/Examples/Manager/PartialPostBacks/DefaultCS.aspx

All the best,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kosal
Top achievements
Rank 1
answered on 27 Aug 2008, 01:55 PM
Thank you.
The partial postback method worked for me.
0
Logan Marshall
Top achievements
Rank 2
Iron
answered on 07 Jun 2017, 12:40 PM
Hey, can you post how you download a file with partial ajaxifcation?
Tags
Ajax
Asked by
Kosal
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Kosal
Top achievements
Rank 1
Logan Marshall
Top achievements
Rank 2
Iron
Share this question
or