In your code there is a big error!
Response.ContentType="image/JPEG";
Response.AppendHeader("Content-Disposition","attachment;
filename=img1.jpg");
Response.WriteFile(@"c:\img1.jpg");
Response.Flush();
with this code you send on client a jpg!
The result is the same as you write
http://server/img1.jpg....
if you write a javascript in an imige it doesn't work!
Response.Write("<script>window.close();</script>");
Is the same if you edit a Jpg with notepad and write inside this code!
If you want to close the page you can do :
1) make a first page with this tag element and script:
<iframe src="webform1.aspx"></iframe>
<script language=javascript>
<!--
window.close();
//-->
</script>
2) make a second page with your code!
the page that response image must have only code for image (no
HTML!). My council is to make a simple page, override the render method
without call the base and than place Response.Write inside this!
example :
protected override void Render(HtmlTextWriter writer)
{
Response.ContentType = "image/jpeg";
Response.AddHeader("Content-Disposition","attachment;filename=img1.jpg");
Response.WriteFile(@"c:\Sample.jpg");
Response.Flush();
}
Brun
"Ryan Moore" <ry*******@hotmail.com> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
I'm trying to make a page that, when opened, displays a file save dialog,
then closes itself (essentially just leaving the file save dialog). Is
this possible? I've tried this:
Response.ContentType="image/JPEG";
//Response.AddHeader ("Content-Length", FileSize.ToString());
Response.AppendHeader("Content-Disposition","attachment;
filename=img1.jpg");
Response.WriteFile(@"c:\img1.jpg");
Response.Write("<script>window.close();</script>");
Response.Flush();
But the page does not close... any ideas?