 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 20th, 2004, 02:23 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to call saveas box in asp.net
i am trying to save a text file in asp.net but the problem is i am able to do that just by fixing the name what if i want to do that by means of user chiice such as , HOW TO CALL SAVE AS box on button click in asp.net and how to get location n name of file where user wanna save the file , how to active brower button.
|
|

August 20th, 2004, 03:07 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Actually The way I See it, I have tried to do that also but in vein :(,But from Javascript you can do that, heres the code
<script language=javascript>
function doSave()
{
var bSuccess;
bSuccess=document.execCommand('SaveAs');
}
but the problem with that is , file saved would b in .htm and u cant save it in any other format,.aspx pages can be saved as "abc.htm"
hope it works
|
|

August 20th, 2004, 08:42 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
What are you trying to save and where do you want it saved? (EG: Server or client)
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

August 20th, 2004, 09:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
if I were u I would use classes in System.IO(not javasciript & HTML!!!!)
(like FileStream,File,....)
--------------------------------------------
Mehdi.:)
|
|

August 23rd, 2004, 02:44 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
mehdi62b was rite ... use the filestream to open or save file will be the best ! else use simple html enuf. if ur extension is not recognize by the web server and it will definitely prompt u for the save file dialog box.
~ Human Knowledge Belongs to the World !
|
|

August 23rd, 2004, 02:45 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
try <a href="test.xxx">Download</a>
~ Human Knowledge Belongs to the World !
|
|

August 24th, 2004, 07:56 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i tried ur code desmond047 , its not working :-(
|
|

August 29th, 2004, 02:16 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please help
|
|

September 1st, 2004, 12:49 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The solution to your problem will be different depending on whether 1. You want to save the file which is sitting on server into the client machine and giving the user option to change the name.
2. You want to save the file from the client machine to the server.
If your need is 1. then follow what desmond is saying
or if your need is 2. then use <input type=file....> in your asp.net page and in the code behind file save the submitted file into server.
|
|

September 30th, 2004, 11:56 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Add a button to your web form and use this code in the button click event handler:
string path = @"C:\...\abc.doc";
Response.ContentType="application/ms-word";
Response.AddHeader( "content-disposition","attachment; filename=Worddocument.doc");
FileStream sourceFile = new FileStream(path, FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
----------------
The above code opens the SaveAs dialog box because of Response.AddHeader method and than it can let the user save the file in the desired location.
The above code right now saves a microsoft word document. if you want to save a text file.. change the Response.Content type to "text".
|
|
 |