Click here to Skip to main content
15,920,688 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried using Javascript but still i can not print it

What I have tried:

<pre>function lnkPrint() {
            var printContent = document.getElementById('<%=GridView1.ClientID %>');
            var printWindow = window.open("All Records", 
            "Print Panel", 'left=50000,top=50000,width=0,height=0');
            printWindow.document.write(printContent.innerHTML);
            printWindow.document.close();
            printWindow.focus();
            printWindow.print();
        }
Posted
Updated 26-Jun-18 2:28am
Comments
Kornfeld Eliyahu Peter 26-Jun-18 8:03am    
Are you looking to print part of your page? You can use @media in your CSS to hide parts when printing (and actually to totally re-design your page), so simple Ctrl+P will do...
Member 13878450 26-Jun-18 8:32am    
I want to print gridview data.

1 solution

You can't print the page in C# - that runs only on the Server, and has no access at all to your client printer.
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 26-Jun-18 8:30am    
The code is clearly JS...
OriginalGriff 26-Jun-18 8:32am    
Precisely - and the question subject is clearly C# ... my guess is he found some javascript and wants it to work on his server... :sigh:

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