如何使用中继器控件内的链接,单击该链接时询问是否要下载或保存到硬盘 [英] How to use a link inside a repeater control that when clicked asks whether to download or save to hard disk

查看:128
本文介绍了如何使用中继器控件内的链接,单击该链接时询问是否要下载或保存到硬盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
我已经制作了一个网络应用程序,可以在其中上传文件,现在我想下载已上传的文件.我所有的文件都存储在服务器上名为"Uploads"的文件夹中.上传文件时,其详细信息会记录在Mysql数据库中(FileName,FileLength,FileType,DateAdded).

现在,我已使用中继器控件从数据库中获取上载/附件的详细信息,并像这样列出它们:

文件名:Ash.doc
文件类型:doc
档案长度:10kb
日期:2010年12月5日

我希望能够单击上面的文件名,然后提供在Web浏览器中查看或将文件保存到硬盘上.

我该怎么做呢?有人可以解释一下,也许提供一个例子.

HI
I have made a web app where i can upload files, now i want to download files that have been uploaded. All my files are stored on a folder called "Uploads" on the server. When a file is uploaded, its details are recorded in a Mysql database(FileName, FileLength,FileType, DateAdded).

Now i have used a repeater control to get the uploads/attachments details from the database and list them like this:

File Name: Ash.doc
File Type: doc
File Length: 10kb
Date: 12/05/2010

I want to be able to click on the filename above and then be offered to view in web browser or save file to hard disk.

How do i go about doing this? Can someone please explain and perhaps provide an example. Any help will be much appreciated

推荐答案

在asp.net中下载文件:
在ASP.NET中使用另存为"对话框下载文件 [ http://forums.asp.net/t/1311359.aspx [ http://forums.asp.net/t/1541684.aspx [ http://forums.asp.net/t/1539730.aspx [ http://bytes .com/topic/asp-net/answers/424911-how-create-linkbutton-repeater-control-dataset [
Downloading a file in asp.net:
Downloading a File with a Save As Dialog in ASP.NET[^]

Check the links below, they are about downloading file by clicking LinkButton/ImageButton column in a GridView. You will be able to implement it for Repeater control.

http://forums.asp.net/t/1311359.aspx[^]
http://forums.asp.net/t/1541684.aspx[^]
http://forums.asp.net/t/1539730.aspx[^]

[Added]
And yes this one for your Repeater Control: http://bytes.com/topic/asp-net/answers/424911-how-create-linkbutton-repeater-control-dataset[^]


我相信您需要两个链接或一个中间页面,以便能够在浏览器中进行下载和查看之间进行选择. Response.BinaryWrite是您向下发送文件的方式,您只需设置标题以说明它是下载文件还是在浏览器中查看过.
I believe you''d need two links or an intermediate page to be able to choose between a download and viewing in the browser. Response.BinaryWrite is how you send a file down, you just set the headers to say if it''s a download or viewed in the browser.


这篇关于如何使用中继器控件内的链接,单击该链接时询问是否要下载或保存到硬盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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