Click here to Skip to main content
12,890,879 members (56,605 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Hi All,

I have a web application and in that I have a folder named as Download and I have a docx file as instructions.docx.
In aspx page I took a button and onlick button I want to download instructions.docx from its path means "~/Download/instructions.docx" .I tried my best but I am unable to do it.

Please help me in sorting out my problem.

Thanking You.
Mohd. Wasif
Posted 14-Feb-11 0:13am
Updated 9-Aug-16 21:20pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Use this code on Button click
Response.Redirect("~/Download/instructions.docx");


It is very simple.On clicking this it will display the Options, based on this you can save it by selceting your Location.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

If you want to force save as dialog then see the following

http://aspalliance.com/259[^]

http://www.west-wind.com/weblog/posts/76293.aspx[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hello Mohd.Wasif

You can simply do it with the help of
Response.Redirect("~/Download/instructions.docx");


It is working perfectly.
When you click on the Button.. The file Download box will appear having the option of Open, Save and Cancel..


Hope this will help you.

Regards
Shweta
:rose:
  Permalink  
Comments
Sandeep Mewara 14-Feb-11 7:59am
   
Good answer. 5!
ShwetaSaxena 15-Feb-11 3:42am
   
@Sandeep Thanks
ridoy 8-Aug-16 6:44am
   
a 5.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

write the following code on button click event

Response.Redirect("~/Download/instructions.docx");
  Permalink  
v2
Comments
Sandeep Mewara 14-Feb-11 7:59am
   
Yep!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

Dim downloadFile As New System.IO.FileInfo(outputFileName)
          If downloadFile.Exists Then
              context.Response.Clear()
              context.Response.ContentType = "application/pdf"
              context.Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", downloadFile.Name))
              context.Response.AddHeader("Content-Length", downloadFile.Length.ToString())
              context.Response.TransmitFile(downloadFile.FullName)
              context.Response.Flush()
          Else
              Throw New Exception("File not found")
          End If
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 10 Aug 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100