473,396 Members | 2,076 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.

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 3454
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
5
by: kevin | last post by:
Hi, Any help with this would be really appreciated! I'm trying to download a file from a remote server. The access permissions is okay but the problem I'm facing is that the file is getting...
4
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. ...
4
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the...
10
by: GJP | last post by:
Hello. Ive been asked to make my own notepade for college assignment. All ig going well, but i cant get the save to work. I can get Save a (shows dialog box), i can get it to just save too,...
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
3
by: fiefie.niles | last post by:
I would like to save a web page to a file and have the hyperlinks work when I bring the file back up. If the web page has a hyperlink like the following <a href="OurWeb/News/abcFile.htm">, after...
3
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" +...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.