I got stuck here,
i have dynamic table that i want to print. So i make session to pass it into web control. Unfortunately, it doesn't run smooth.
Here are my code :
protected void bt_print_click(object sender, EventArgs e)
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
panelBilling.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
Session["ctrl"] = s;
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx?rep=1','PrintMe','height=680px,width=1024px,scrollbars=1');</script>");
}
And the Print.aspx.cs code:
protected void Page_Load(object sender, EventArgs e)
{
Control ctrl = (Control)Session["ctrl"];
PrintHelper.PrintWebControl(ctrl);
}
I always got error message :
"Unable to cast object of type 'System.String' to type 'System.Web.UI.Control'."
on
(Control)Session["ctrl"]
part. I have use this method many time and no problems before. Anyone has any idea? Thanks.