Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 25, 2009 03:03 PM by dangerouschotu
0 Points
1 Post
Nov 24, 2009 11:20 PM|LINK
Hi all,
I'm trying to force the download of files using window.open('downloadfile.aspx?id=xxxx','') but with IE new window gets closed and the download confirmation box is not shown :(
This user has the same problem:
http://forums.asp.net/p/1402084/3040672.aspx#3040672
And this one too:
http://stackoverflow.com/questions/208993/asp-net-file-download-does-not-work-with-ie7
but i haven't found a solution... :(
This is the code i'm using to force file download on download.aspx:
Response.Clear();
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", fileName));
Response.TransmitFile(MapPath("files/" + fileName));
Response.End();
Thanks
All-Star
29935 Points
5821 Posts
Nov 25, 2009 01:52 AM|LINK
Pop Up blocker in play?
Does it work if you just do it in the same page? AKA, you use window.location.href = filePath;
Have you tried to use a hidden iframe? Set the source of a hidden iframe with the file path.
Eric
Participant
1021 Points
407 Posts
Nov 25, 2009 03:03 PM|LINK
i am agree with A1ien51 use this code
string path =""// file path
Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", "window.open('.." + path + "','');", true);
jm.villagra
0 Points
1 Post
window.open() and download file problem
Nov 24, 2009 11:20 PM|LINK
Hi all,
I'm trying to force the download of files using window.open('downloadfile.aspx?id=xxxx','') but with IE new window gets closed and the download confirmation box is not shown :(
This user has the same problem:
http://forums.asp.net/p/1402084/3040672.aspx#3040672
And this one too:
http://stackoverflow.com/questions/208993/asp-net-file-download-does-not-work-with-ie7
but i haven't found a solution... :(
This is the code i'm using to force file download on download.aspx:
Response.Clear();
Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", fileName));
Response.TransmitFile(MapPath("files/" + fileName));
Response.End();
<div style="position: absolute; left: -10000px; top: 91px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Response.Clear();</div> <div style="position: absolute; left: -10000px; top: 91px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Response.ContentType = "text/plain";</div> <div style="position: absolute; left: -10000px; top: 91px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", fileName));</div> <div style="position: absolute; left: -10000px; top: 91px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Response.TransmitFile(MapPath("files/" + fileName));</div> <div style="position: absolute; left: -10000px; top: 91px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Response.End();</div>Thanks
A1ien51
All-Star
29935 Points
5821 Posts
Re: window.open() and download file problem
Nov 25, 2009 01:52 AM|LINK
Pop Up blocker in play?
Does it work if you just do it in the same page? AKA, you use window.location.href = filePath;
Have you tried to use a hidden iframe? Set the source of a hidden iframe with the file path.
Eric
dangerouscho...
Participant
1021 Points
407 Posts
Re: window.open() and download file problem
Nov 25, 2009 03:03 PM|LINK
i am agree with A1ien51 use this code
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">string path = newfile.Remove(0, 1);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", "window.open('.." + path + "','');", true);</div> <div></div>string path =""// file path
Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", "window.open('.." + path + "','');", true);
<div></div>
Please 'mark as answer' my post if they are helpful.