Problem while printing the page

Posted by Amritha444 under ASP.NET on 2/1/2011 | Points: 10 | Views : 1448 | Status : [Member] | Replies : 2
Hi all


I have a code to print content of page it works fine.But when i used editor control we get along with ajax toolkit,the print function not works.

my code is
<pre lang="cs">function printdiv(printpage)
{
var headstr = &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;;
var footstr = &quot;&lt;/body&gt;&quot;;
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}</pre>

How to change the code to be applicable to editor also.




Responses

Posted by: Prabhakar on: 2/1/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Amritha444

like this. . u want to print ur edit control .so u add this script on print button

Button5.Attributes["onclick"] = "javascript:CallPrint('divPrint');";

and script in <HEAD> Section
<script type="text/javascript" >

function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('print.htm','PrintWindow','letf=0,top=0,width=800%,height=600,toolbar=1,scrollbars=1,status=1');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}

</script>

Best Regard's
Prabhakar

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amritha444 on: 2/1/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks prabhakar for your response

i use this coding in the button click
<input id="btnPrint" type="button" style="width: 78px" value="Print" onclick="printdiv('div_print');" /></td>

according to the id matter displays in editor control but when give print option out line of that editor only comes

i want to display those content also





Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response