Hi Vanessa,
Refer below sample.
HTML
<asp:Button ID="btnShowPopup" runat="server" Text="Show Popup" />
<div id="dialog" style="display: none">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" EmptyDataText="No files uploaded">
<Columns>
<asp:BoundField DataField="Text" HeaderText="File Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" Text="Download" CommandArgument='<%# Eval("Value") %>'
runat="server" OnClick="DownloadFile"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=btnShowPopup]").click(function () {
$("#dialog").dialog({
title: "File Details",
width: 250,
buttons: {
Ok: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
});
</script>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] filePaths = System.IO.Directory.GetFiles(Server.MapPath("~/Files/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(System.IO.Path.GetFileName(filePath), filePath));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
}
protected void DownloadFile(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
Response.WriteFile(filePath);
Response.End();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim filePaths As String() = IO.Directory.GetFiles(Server.MapPath("~/Files/"))
Dim files As List(Of ListItem) = New List(Of ListItem)()
For Each filePath As String In filePaths
files.Add(New ListItem(IO.Path.GetFileName(filePath), filePath))
Next
GridView1.DataSource = files
GridView1.DataBind()
End If
End Sub
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
Dim filePath As String = TryCast(sender, LinkButton).CommandArgument
Response.ContentType = ContentType
Response.AppendHeader("Content-Disposition", "attachment; filename=" & IO.Path.GetFileName(filePath))
Response.WriteFile(filePath)
Response.End()
End Sub
Screenshot