Hi @Gani_tpt,
It's possible that the file cannot be accessed for browser security reasons.
Perhaps you can change it to the same implementation as for images, and view the PDF by getting the bytes.
<iframe id="iframe" runat="server" width="500" height="500"></iframe>
protected void Display(object sender, EventArgs e)
{
int rowIndex = Convert.ToInt32(((sender as LinkButton).NamingContainer as GridViewRow).RowIndex);
GridViewRow row = gvCustomers.Rows[rowIndex];
string FPath = (row.FindControl("HiddenField1") as HiddenField).Value;
string sMineType = MimeMapping.GetMimeMapping(FPath);
if (!string.IsNullOrEmpty(FPath))
{
byte[] rawFile = File.ReadAllBytes(FPath);
iframe.Attributes["src"] =$@"data:{sMineType};base64,{Convert.ToBase64String(rawFile)}";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.