When a user clicks on a link, it opens a new window (since target="_blank") calls an xyz.ASPX page that will dynamically create an PDF invoice, saving it into a Database (not a physical location) and then I need to be able to open the PDF file within the ASPX page.
Right now whats happening is that the aspx that generates the PDF file is called, it does its stuff but then opens Acrobat to display the invoice PDF. However, the xyz.aspx page is blank and does not display anything. I do not like this and would like xyz.aspx to display the PDF file.
From my research, it seems that if you want to display the PDF within the ASPX page, you need an iFrame or a custom control. However, since the PDF is dynamically created and not stored on disk, how do I set the source for the iFrame. Is there a way to set the src as a response object or some other in-memory object?
Is there an easy way of doing this? I dont want to use a custom control. I am using .NET 3.5 and C# with Master pages and CSS themes but I have disabled it for this page.
Source *xyz.aspx:*
`<%@ Page language="c#" EnableTheming="false"
ContentType="application/pdf" Codebehind="xyz.aspx.cs" AutoEventWireup="True" Inherits="namespace1.xyz" %>
'
xyz.aspx.cs (gets the PDF file from the DB and then writes to Response object)
protected void Page_Load(object sender, EventArgs e)
{
byte[] pdfBinaryFile = GetPDFFileFromDB(PDFId);
if(pdfBinaryFile != null)
Response.BinaryWrite(pdfBinaryFile);
}