Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I used;
function Print()
                {
                    var divToPrint = document.getElementById('grid');
                    newWin = window.open("");
                    newWin.document.write(divToPrint.outerHTML);                 
                    newWin.print();
                    newWin.close();
                }`

but this code snippet print only get data in the table..I want to all table print...
Posted
Comments
John C Rayan 17-Feb-15 8:04am    
Did you try with .innerHTML rather than outerHTML
seydost 17-Feb-15 8:11am    
Yes,I tried..All data were lined with
John C Rayan 17-Feb-15 9:16am    
you have to use CSS to create the border. You don't seem to be having table grid lines in your table.
seydost 17-Feb-15 9:18am    
Thank you !
John C Rayan 17-Feb-15 10:07am    
Can you please let us know when you have completed this one so that we can close it

problem solved...I forgot table with border..thx
 
Share this answer
 
Comments
[no name] 18-Feb-15 5:14am    
This is not a solution.put your correct solution here or accept the right answer to solve this question :)
Use this code..


XML
<script>
      function myFunction() {
          //window.print();


          var panel = document.getElementById("<%=pnlContents.ClientID %>");//put your table inside a panel.
          var printWindow = window.open('', '', 'height=800,width=800');
          printWindow.document.write('<html><head><title>DIV Contents</title>');
          printWindow.document.write('</head><body >');
          printWindow.document.write(panel.innerHTML);
          printWindow.document.write('</body></html>');
          printWindow.document.close();
          setTimeout
          (function () {
              printWindow.print();
          }, 500);
          return false;
      }
</script>


Ref : Print a doument with CSS
 
Share this answer
 
v2
Comments
[no name] 18-Feb-15 4:59am    
now its working fine?
[no name] 18-Feb-15 5:03am    
try also this http://www.codeproject.com/Articles/13246/Print-a-doument-with-CSS

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900