Hi eliaso,
Check this example. Now please take its reference and correct your code.
HTML
<asp:LinkButton ID="lnkView" runat="server" Text="View PDF" OnClick="View"></asp:LinkButton>
<hr />
<asp:Literal ID="ltEmbed" runat="server" />
Namespaces
C#
using System.IO;
VB.Net
Imports System.IO
Code
C#
protected void View(object sender, EventArgs e)
{
string tags = "";
foreach (string file in Directory.GetFiles(Server.MapPath("~/Files/"), "*.pdf"))
{
string fileName = Path.GetFileName(file);
string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"500px\" height=\"17Check this example. Now please take its reference and correct your code.0px\">";
embed += "If you are unable to view file, you can download from <a href = \"{0}\">here</a>";
embed += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
embed += "</object><br/><br/>";
tags += string.Format(embed, ResolveUrl(Path.Combine("~/Files/", fileName)));
}
ltEmbed.Text = tags;
}
VB.Net
Protected Sub View(ByVal sender As Object, ByVal e As EventArgs)
Dim tags As String = ""
For Each file As String In Directory.GetFiles(Server.MapPath("~/Files/"), "*.pdf")
Dim fileName As String = Path.GetFileName(file)
Dim embed As String = "<object data=""{0}"" type=""application/pdf"" width=""500px"" height=""17Check this example. Now please take its reference and correct your code.0px"">"
embed += "If you are unable to view file, you can download from <a href = ""{0}"">here</a>"
embed += " or download <a target = ""_blank"" href = ""http://get.adobe.com/reader/"">Adobe PDF Reader</a> to view the file."
embed += "</object><br/><br/>"
tags += String.Format(embed, ResolveUrl(Path.Combine("~/Files/", fileName)))
Next
ltEmbed.Text = tags
End Sub
Screenshot