Best way to do a Binary Data Download from an Ajax Popup

Best way to do a Binary Data Download from an Ajax Popup

  

Hi All - Looking for recommendations on best way to accomplish this.   The user is on a full screen list page, and selects a link on the page.  An Ajax Rich Widgets Popup edit box appears, where the user must select an item from a drop down then presses a "download" button.   When the download button is pressed, an action is called which returns binary data which I then want to present to the user using the download widget (instead of an end statement).

I've tried the following:
1.  Main Screen Calls Popup, user selects item, Notify/Widget sends the key to the parent page, On Notify kicks in for the download screen action, that action generates the binary data, and then hits the download step.

2.  Main Screen Calls Popup, user selects item, users presses download button, that action generates the binary data, I send a close popup, and then it hits the download step.

Problems:
1.  Using method #1 above, I can debug it all the way to the download step.  It hits the download step with valid binary data but just "ends"  the end user never gets a download.

2.  Using method #2 above, during debug, when it hits the download step, I get an error message about not being able to modify the headers of the page after the page is rendered.

Do you have any suggestions on the best way to proceed with this?

Thanks

Ken
Hi Ken,

I believe you can not do a download in an Ajax call.
An option would be to redirect to another page and do the download in the preparation of that page.

Cheers,
Tiago Simões
Hi Ken,

U something like your method #2..

Main screen with two actions. Action1 with the generation of your content to download and Action2 calling action Widget_Click from RichWidgets, the widget should be an hidden button with destination Action1 and method submit. Set the destination of your Popup_Editor to Action2. When notifying parent screen u can pass as argument the type selected by user. 

Cheers,
 
On your popup u must notify and then close it

We ended up redirecting to another screen and put the dowload code in the prep area.  Because the new screen visual area does not get executed (download in is preparation) the user sees no visual difference.

Thanks for the advice!

Ken