I'm using a PDF component that takes HTML and creates a PDF that I'm putting in the response as an attachment(which prompts 'open or save' dialog box. The HTML I need to pass to the PDF object is the main Panel control on the page(it has 3 child controls, too). The problem is that since I'm doing this in Page.Page_Load, the Panel.Load hasn't fired and doesn't contain the HTML yet. At least I think this is the problem, but not positive. I've tried calling Panel.RenderControl but that's still blank output. Any advice?
In the page_load...
In the page_load...
Code:
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
ReportLayoutMain.RenderControl(htmlTextWriter);
stringWriter = (System.IO.StringWriter)htmlTextWriter.InnerWriter;
thePDFDoc.AddImageHtml(stringWriter.ToString());
byte[] theData = thePDFDoc.GetData();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename=report.pdf");
Response.AddHeader("content-length", theData.Length.ToString());
Response.BinaryWrite(theData);