how to open a .pdf file in a panel or iframe using asp.net c#
- by rahul
I am trying to open a .pdf file on a button click. I want to open a .pdf file into a panel or some iframe. With the following code i can only open .pdf file in a separate window or in a save as mode.
string filepath = Server.MapPath("News.pdf");
FileInfo file = new FileInfo(filepath);
if (file.Exists)
{
Response.ClearContent();
Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = ReturnExtension(file.Extension.ToLower());
Response.TransmitFile(file.FullName);
Response.End();
}
how to assign a iframe to the below line
Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name);