Jump to content

Last Row Contents Of Table In A Page Break While Printing To Paper


monoloox

Recommended Posts

Hi ...I intend to print a table to paper but when I print it using IE, instead of printing the whole row at the next page, the last row breaks into two parts and the contents of it are displayed incompletely. I've tried so many different solutions but none of them worked for me.Here is my code. I want to print the table using JavaScript

StringWriter sw = new StringWriter();		HtmlTextWriter hw = new HtmlTextWriter(sw);		table.Style[HtmlTextWriterStyle.BorderCollapse] = "collapse";		table.Style["page-break-after"] = "auto";		table.Style["page-break-inside"] = "avoid";		table.Style["display"] = "block";		table.RenderControl(hw);		string gridHTML = sw.ToString().Replace("\"", "'")			.Replace(System.Environment.NewLine, "");		StringBuilder sb = new StringBuilder();		sb.Append("<script type = 'text/javascript'>");		sb.Append("window.onload = new function(){");		sb.Append("var printWin = window.open('', '', 'right=0");		sb.Append(",top=0,width=1000,height=600,status=0,toolbar=1,scrollbars=1');");		sb.Append("printWin.document.write(\"");		sb.Append(gridHTML);		sb.Append("\");");		sb.Append("printWin.document.close();");		sb.Append("printWin.focus();");		sb.Append("printWin.print();");		sb.Append("printWin.close();};");		sb.Append("</script>");		ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());

Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...