By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Save to file

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.