| |

VerySource

 Forgot password?
 Register
Search
View: 930|Reply: 8

Jiqiu: How to pop up a file save dialog box on the C # web application page

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-2 21:30:01
| Show all posts |Read mode
Dear experts:
    When I click the "Download" button, how can I make it pop up a file save dialog box, just like the "Save As" format of a text document. There doesn't seem to be a SaveFile type control in the C # .net web application! !! !! !!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-13 23:15:01
| Show all posts
When the hyperlink of your button points to a file (non-page and image format), the option to download and save as will appear when you click
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-5-14 09:45:02
| Show all posts
If it is downloaded, the browser will automatically pop up the "Save" dialog box!
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-14 17:00:01
| Show all posts
The upstairs makes sense
There are many controls to open the file dialog
There is a file control in html
Reply

Use magic Report

0

Threads

32

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-5-15 14:45:01
| Show all posts
ASP.NET downloads a file directly instead of opening it in a browser
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-15 14:00:02
| Show all posts
thanks Thank you all for your great help. Maybe I am not very clear.
It's like this: In the web application, I wrote a "download" button, when you click the button, you need to use the code to generate a dialog box to save the file, just like save, enter the file name and path in the dialog box, click ok will do. All I need is the file name and path entered by the user.
   The question is: how to generate a save dialog with code? It seems that such a dialog box cannot be directly generated in .NET!
  Suppose I want to write a saveas() function with a javascript script. This function can generate a "save file" dialog box. I save it as a saveas.js file. How can I embed this file in a C#.NET Web application? ? The event of my "download" button can directly call the saveas() function.

I included the file with <SCRIPT src="saveas.js" type="text/javascript"> </script> in the html source of the web program, and used the statement in the "download" event: this.Response.Write( "<script language ='javascript'>saveAs('saveas','download',true)</script>");, but there is still an error when calling: Missing object!
    Please help! Thanks a lot! ! !
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-11 21:00:02
| Show all posts
private void FileDownload(string FullFileName)
{
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer=false;
Response.ContentType="application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-11 21:15:01
| Show all posts
Just add the above method directly to your program.
This is how I use it, try it,
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 United States

 Author| Post time: 2020-8-14 08:45:01
| Show all posts
Ok, it's solved, thank you brothers upstairs? The FileDownload() method is really good! ! ! ! ! ! ! ! ! ! ! ! !
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list