如何使用C#和ASP.NET上的链接按钮上传和下载文件谢谢 [英] How to upload and download a file using only a linkbutton on C# and ASP.NET thanks

查看:106
本文介绍了如何使用C#和ASP.NET上的链接按钮上传和下载文件谢谢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to upload and download a file using only a linkbutton on c# and asp.net thanks





我尝试了什么:



我是编程的新手,我需要一些帮助来只下载一个文件我已经完成了上传一些文件,但我无法使用linkbutton下载



What I have tried:

im new on the programming and i need some help to download only a file i already done uploading some file but i cant download using a linkbutton

推荐答案

创建一个指向您文件的超链接。
Create a hyperlink to your file.


引用:

我不知道如何使用linkbutton下载文件。

and i dont know how to download the file using the linkbutton.



LinkBut​​ton 就像一个普通的按钮, CSS 就像一个标签。

试试这个




LinkButton is like a normal button with CSS like an anchor Tag.
try this

protected void LinkButton1_Click(object sender, EventArgs e)
       {
           string filePath = "Your file path from the folder";
           Response.ContentType = ContentType;
           Response.AppendHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
           Response.WriteFile(filePath);
           Response.End();
       }


这篇关于如何使用C#和ASP.NET上的链接按钮上传和下载文件谢谢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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