GillouX
GillouX

Reputation: 469

Response.BinaryWrite and Response.Write from a popup

I am in a modal window.

I have an hyperlink which points on an ashx file.

this ashx file use Response.BinaryWrite to push the file for download and I then want to close the modal.

the things is that

if I use

Response.BinaryWrite(myFile);
Response.("<script type='text/javascript'>window.close();</script>");

it does not work.

if I let alone

Response.("<script type='text/javascript'>window.close();</script>");

it works.

Any body having a solution for this ?

thx

Upvotes: 0

Views: 1290

Answers (2)

Gaby Deenen
Gaby Deenen

Reputation: 46

I think you are choosing a wrong approach. AFAIK you use a binary write to send something binary to the client i.e. a pdf The client will not understand that you also send a javascript at the end of a binary stream. You can not combine the binary data and the script

Upvotes: 1

Icarus
Icarus

Reputation: 63956

No, there's no solution because your lines above do two different things:

The first line is basically streaming a file to the user. Until the user responds to the dialog that appears (he either chooses to save or display it on the screen) there's nothing you can do. It seems you are attempting to close the user's dialog automatically but you can't control the user's browser from server side code.

The second line works because all you are doing is sending javascript code that instructs the browser window to close itself. You can't intertwined these 2 things in the same response stream.

Upvotes: 2

Related Questions