468,741 Members | 1,602 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,741 developers. It's quick & easy.

"save file" dialog box in clients

31
hi,

I am developing a system with asp.net, c#, and ajax.

I have an excel file in server in "Server.MapPath("ExcelFiles/Test.xls")".

I want to make it available to save to the disk in client side. I hope save file dialoge box will allow to do this. How can i do this?

thanks

Anushka
May 23 '08 #1
3 2287
Plater
7,872 Expert 4TB
Provide a link to the file? Or at least a page that will serve it up.
You will also need to remember add the content-disposition header to get the save file box to pop up in your clients browser.

Heres part of something I use
Expand|Select|Wrap|Line Numbers
  1. Response.Clear();
  2. Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
  3. Response.ContentType = ContentTypeString;
  4. Response.AddHeader("content-disposition", "attachment; filename=" + FileName);
  5. Response.WriteFile(FullPathFileName);
  6. Response.End();
  7.  
May 23 '08 #2
Curtis Rutland
3,256 Expert 2GB
Your best bet is to present the file for download. You could redirect to a page with a link to the download. But I am pretty sure that you can't use a Save File dialogue, because you can't create client side popups with server side code. But if you present it as a download, the client will get the browser's save file dialog.

hi,

I am developing a system with asp.net, c#, and ajax.

I have an excel file in server in "Server.MapPath("ExcelFiles/Test.xls")".

I want to make it available to save to the disk in client side. I hope save file dialoge box will allow to do this. How can i do this?

thanks

Anushka
May 23 '08 #3
Frinavale
9,735 Expert Mod 8TB
Your best bet is to present the file for download. You could redirect to a page with a link to the download. But I am pretty sure that you can't use a Save File dialogue, because you can't create client side popups with server side code. But if you present it as a download, the client will get the browser's save file dialog.
InsertAlias is correct, you cannot call the "SaveAs" dialog box in ASP.NET.
However you can just use an old-fashioned hyperlink that points to the file. Since Excel files can't be rendered in the browser, the browser itself will open a "SaveAs" dialog box to allow the user to download the file.

Make sure that the folder that contains the Excel file is on the web server or else this will not work.

-Frinny
May 23 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Bill R via AccessMonster.com | last post: by
4 posts views Thread by Richard | last post: by
3 posts views Thread by B-Dog | last post: by
1 post views Thread by Tomas Martinez | last post: by
7 posts views Thread by Tim Slattery | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.