473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

File save dialog

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?
Nov 18 '05 #1
2 2942
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?

Nov 18 '05 #2
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?

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: cathywigzell | last post by:
I have a web page which allows a user to download a file directly to their computer, using IE. I present a file name in a table and the user can then right click on the file name to get a popup...
2
by: Alvo von Cossel I | last post by:
hi, i have a textbox in a form. when you press a Save button, a savefiledialog appears. creating ther file works but everytime you click save, the dialog appears. how do i make the dialog appear...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response ...
3
by: B-Dog | last post by:
I'm checking some files to see if the filenames are in a certain format and if not I want to pull up a dialog box that gives me a save as with the file that is in question. I have all the files in...
24
by: Kelly | last post by:
Hey all - I need a little more help. I don't quite know why my text file or form isn't closing. Short version - this program takes data entered into a textbox, user clicks Save button, Save...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
1
by: sunita | last post by:
Hiii I open a file download dialog from a modal dialog...From the file download dialog i can either save or open the file.. Is there a way i can let the modal dialog that opens the file download...
3
by: ArmageddonAsh | last post by:
I'm trying to make an application that will allow the user to enter data into a flexgrid (that's done) and then save the data from that flexgrid into a CSV file but even though the file is made none...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.