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
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.