how to open a .pdf file in a panel or iframe using asp.net c#

Posted by rahul on Stack Overflow See other posts from Stack Overflow or by rahul
Published on 2010-02-08T12:18:12Z Indexed on 2010/03/28 1:03 UTC
Read the original article Hit count: 388

Filed under:
|

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); 

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#