Hi there,
I use two objects in my page, one for images and another one for PDFs, which I hide or show as needed.
<asp:Image ID="imgRespaldo" runat="server" CssClass="img-fluid" style="display:none" />
<div id="PDFObj" runat="server" class="col-12" style="display:none;" >
<asp:Literal ID="ltObjPDF" runat="server"/>
</div>
Said objects reside inside an updatepanel.
Here's a code example:
private void DisplayImage(GridViewRow Row)
{
StringBuilder embedPDFObj;
string fileName = Row.Cells[2].Text;
string respaldoURL = "~/Respaldos/" + Row.Cells[1].Text + "/" + fileName;
if (fileName.EndsWith(".pdf"))
{
embedPDFObj = new StringBuilder("<object data=\"{0}\" type=\"application/pdf\" width=\"100%\" >");
embedPDFObj.Append("<embed src=\"{0}\" type=\"application/pdf\"></embed>");
embedPDFObj.Append("</object>");
ltObjPDF.Text = string.Format(embedPDFObj.ToString(), ResolveUrl(respaldoURL));
RootCore.SetDisplayStyle(PDFObj, true, UpdPanelImg);
}
else
{
imgRespaldo.AlternateText = fileName;
imgRespaldo.ImageUrl = respaldoURL;
RootCore.SetDisplayStyle(imgRespaldo, true, UpdPanelImg);
}
}
My "SetDisplayStyle" method is in charge of modifying the given control style's display setting.
Hope this helps, cheers!