<script type="text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=div_print.ClientID %>");
var printWindow = window.open('', '', 'height=700,width=800');
printWindow.document.write(panel.innerHTML);
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
function PrintElem() {
debugger;
var panel = document.getElementById("<%=div_print.ClientID %>");
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
mywindow.document.write('<html><head><title>' + document.title + '</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1>' + document.title + '</h1>');
mywindow.document.write(panel.innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
}
</script>
and calling of Javascript function in ASP.NET
protected void btnPrint_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtFileNumber.Text))
{
return;
}
LoadReport();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Javascript", "javascript:PrintPanel(); ", true);
}
No comments:
Post a Comment