Thursday, March 29, 2012

Opening PDF in a new window

Hi
I'm new to .net so if this question is pretty basic - you'll understand!

I'm creating a PDF on the fly (printer friendly version) which is working perfectly. It is being called from a popup window. I'm using the following code to open the PDF file

Response.ContentType = "Application/pdf"
Response.WriteFile(FilePath)
Response.End()

It opens the file fine - but in the popup window. I need it to open in a new window.

Any thoughts?try this code

string m_str_var1 = "window.open(FilePath)";
Response.Write("<script language=javascript>");
Response.Write(m_str_var1);
Response.Write("</script>");

hope it helps
the caller should open a new window, and then make the request to your page for the PDF

0 comments:

Post a Comment