471,354 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Save to file

Following on from the excellent example at
http://www.c-sharpcorner.com/Code/20...ridToExcel.asp
on how to save a data-grid to excel file, how can I extend the example such
that when the user click on the button a popup appear in IE to say "Do you
want to save or open file?"
Nov 19 '05 #1
5 3304
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

"Patrick" <qu*******@newsgroup.nospam> wrote in message
news:F5**********************************@microsof t.com...
Following on from the excellent example at
http://www.c-sharpcorner.com/Code/20...ridToExcel.asp on how to save a data-grid to excel file, how can I extend the example such that when the user click on the button a popup appear in IE to say "Do you
want to save or open file?"

Nov 19 '05 #2
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" wrote:
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

"Patrick" <qu*******@newsgroup.nospam> wrote in message
news:F5**********************************@microsof t.com...
Following on from the excellent example at

http://www.c-sharpcorner.com/Code/20...ridToExcel.asp
on how to save a data-grid to excel file, how can I extend the example

such
that when the user click on the button a popup appear in IE to say "Do you
want to save or open file?"


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

Patrice

--

"Patrick" <qu*******@newsgroup.nospam> a écrit dans le message de
news:8A**********************************@microsof t.com...
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" wrote:
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

"Patrick" <qu*******@newsgroup.nospam> wrote in message
news:F5**********************************@microsof t.com...
Following on from the excellent example at

http://www.c-sharpcorner.com/Code/20...ridToExcel.asp
on how to save a data-grid to excel file, how can I extend the example

such
that when the user click on the button a popup appear in IE to say "Do you want to save or open file?"


Nov 19 '05 #4
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" <qu*******@newsgroup.nospam> wrote in message
news:8A**********************************@microsof t.com...
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" wrote:
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

"Patrick" <qu*******@newsgroup.nospam> wrote in message
news:F5**********************************@microsof t.com...
Following on from the excellent example at

http://www.c-sharpcorner.com/Code/20...ridToExcel.asp
on how to save a data-grid to excel file, how can I extend the example

such
that when the user click on the button a popup appear in IE to say "Do you want to save or open file?"


Nov 19 '05 #5
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.)

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by a | last post: by
4 posts views Thread by Richard | last post: by
4 posts views Thread by sunilj20 | last post: by
10 posts views Thread by GJP | last post: by
10 posts views Thread by Henok Girma | last post: by
1 post views Thread by liuliuliu | last post: by
3 posts views Thread by =?Utf-8?B?YXNkZg==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.