在按钮点击事件中下载asp.net中的文件 [英] Download a file in asp.net on button click event

查看:210
本文介绍了在按钮点击事件中下载asp.net中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个Web应用程序,我有一个名为Download的文件夹,我有一个docx文件作为instructions.docx。

在aspx页面中,我选择了一个按钮和onlick按钮我要从其路径下载instructions.docx表示〜/ Download / instructions.docx。我尽我所能但我无法做到。



请帮我解决问题。



感谢你。

莫哈末。 Wasif

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

推荐答案

在按钮上单击使用此代码

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.


如果你想强制保存为对话框,请看以下



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



http:// www.west-wind.com/weblog/posts/76293.aspx [ ^ ]
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[^]


Hello Mohd.Wasif



你可以简单地用
Hello Mohd.Wasif

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





我是完美工作。

单击按钮时,文件下载框将显示打开,保存和取消选项..





希望这会对你有所帮助。



问候

Shweta

:玫瑰:



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:


这篇关于在按钮点击事件中下载asp.net中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆