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

Download Files with Ajaxified Control Not working

2 Answers 179 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Geoff Van Brunt
Top achievements
Rank 1
Geoff Van Brunt asked on 05 May 2007, 02:04 AM
As per the documentation I am attempting to initiate a download from an ajaxified control like this:

RadAjaxPanel1.ResponseScripts.Add(String.Format(@"window.location.href = ""{0}"";", http://yoursite.com/Your_File));

However that brings up IE's Information bar. Once the user clicks on "download file..." the page "refreshes" to the state when it first loaded prior to any ajax requests and the file does not download.

Is there any way to work around this? I understand that files will not download automatically without user intervention since XP SP2, but isn't clicking on a button to initiate an ajax request "user intervention" or is that "broken" because of the callback?

2 Answers, 1 is accepted

Sort by
0
surfer
Top achievements
Rank 1
answered on 06 May 2007, 09:08 AM
I haven't tried this locally unfortunately (requirements still force me to keep IE6 here)... but the download with Ajax problem seems to be common.

If registering javascript from the server forces security, then maybe you can use the approach described in the following Code Library project?

http://www.telerik.com/community/code-library/submission/b311D-ttcbe.aspx

Basically, the idea is to hook the OnRequestStart client-side event of the Ajax call and cancel the Ajax (arguments.EnableAJAX = False) only when the control initiating the request (argument.EventTarget) is the file to be downloaded.

Hopefully this will work in your case, more details and sample code is available at the link above.

I also believe that it would be a very good idea if telerik included a "File Downloading / File Uploading" section in their rad Ajax help files (both standard rad Ajax and the Prometheus version), since it can get tricky...
0
Geoff Van Brunt
Top achievements
Rank 1
answered on 06 May 2007, 10:08 PM
Thanks for the heads up on the project however it doens't apply in my case. I'm pretty sure even if the action was taken via postback as opposed to a callback it would still pop up the information bar.

I think this suppress download thing was absolutly stupid on MS's behalf and served no useful purpose other than to show off the information bar. All they did is trade a File Download dialog for the information bar and then not let the user download the file. How that helped security is beyond me. The rest of SP2 was really useful, but that just broke critical functionality on the web...

I've decided I will popup a radwindow after the callback with a link to the file in IE. Every other browser will just download the file....
Tags
Ajax
Asked by
Geoff Van Brunt
Top achievements
Rank 1
Answers by
surfer
Top achievements
Rank 1
Geoff Van Brunt
Top achievements
Rank 1
Share this question
or