Save to file

E

Eliyahu Goldin

I didn't look into the example.

Generally, to produce a popup request you would need to handle client-side
onclick event in the way:

onclick="return confirm("Do you want to save file?")";

This will open a popup with the question and buttons "Ok" and "Cancel". If
you want another buttons, like "Save" and "Open", you need to make your own
html dialog that will return different values depending on selection.

You can set client-side onclick handler in the code with Attributes
collection.

Eliyahu
 
G

Guest

I think you misunderstood. I do NOT want JavaScript popups, but rather the
default Internet Explorer pop-up.

? Some files can harm your computer. If the file information below looks
suspicious, or you do not fully trust the source, do not open or save this
file.
Filename: datagrid.xls
Filetype: Application
From: localhost

Would you like to open the file or save it to the computer?
[Open] [Save] [Cancel] [More Info]

How can I generate the Response so the user get prompted to save or open the
DataGrid as an Excel file instead of opening in the current window by default?
 
P

Patrice

Try :
http://support.microsoft.com/kb/260519/en-us
(How to raise a "file download" dialog box for a known mime type).

Patrice

--

Patrick said:
I think you misunderstood. I do NOT want JavaScript popups, but rather the
default Internet Explorer pop-up.

? Some files can harm your computer. If the file information below looks
suspicious, or you do not fully trust the source, do not open or save this
file.
Filename: datagrid.xls
Filetype: Application
From: localhost

Would you like to open the file or save it to the computer?
[Open] [Save] [Cancel] [More Info]

How can I generate the Response so the user get prompted to save or open the
DataGrid as an Excel file instead of opening in the current window by default?

Eliyahu Goldin said:
I didn't look into the example.

Generally, to produce a popup request you would need to handle client-side
onclick event in the way:

onclick="return confirm("Do you want to save file?")";

This will open a popup with the question and buttons "Ok" and "Cancel". If
you want another buttons, like "Save" and "Open", you need to make your own
html dialog that will return different values depending on selection.

You can set client-side onclick handler in the code with Attributes
collection.

Eliyahu


http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp
 
E

Eliyahu Goldin

Try to trick the browsers by setting bogus Mime-Type. If it doesn't
recognize the Mime-Type, it might produce the dialog you want to ask the
user for further instructions. Unless it decides based on the file
extension...

Eliyahu


Patrick said:
I think you misunderstood. I do NOT want JavaScript popups, but rather the
default Internet Explorer pop-up.

? Some files can harm your computer. If the file information below looks
suspicious, or you do not fully trust the source, do not open or save this
file.
Filename: datagrid.xls
Filetype: Application
From: localhost

Would you like to open the file or save it to the computer?
[Open] [Save] [Cancel] [More Info]

How can I generate the Response so the user get prompted to save or open the
DataGrid as an Excel file instead of opening in the current window by default?

Eliyahu Goldin said:
I didn't look into the example.

Generally, to produce a popup request you would need to handle client-side
onclick event in the way:

onclick="return confirm("Do you want to save file?")";

This will open a popup with the question and buttons "Ok" and "Cancel". If
you want another buttons, like "Save" and "Open", you need to make your own
html dialog that will return different values depending on selection.

You can set client-side onclick handler in the code with Attributes
collection.

Eliyahu


http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp
 
S

Steven Cheng[MSFT]

Hi Patrick,

I think the kb article Patrice provided may help you do it. Also, in
ASP.NET we can just apply this as below in our page's c ode:

private void Page_Load(object sender, System.EventArgs e)
{


Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/zip";
Response.AddHeader( "Content-Disposition",
"attachment;filename=mypackage.zipl");

Response.WriteFile(Server.MapPath("~/files/myzip.zip"));

Response.End();
}

Also, you can search for many threads or articles on web discussing the
same question. Hope helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top