Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a asp.net web application for INVENTORY MANAGEMENT SYSTEM.
I need to print a invoice/bill on every transactions. i have created code for preparing the bill in a gridview. What i want now is to print the content of that gridview(bill) on button click.
I have tried using the javascript function
JavaScript
function printPartOfPage(elementId) {
        var printContent = document.getElementById(elementId);
        var windowUrl = 'about:blank';
        var uniqueName = new Date();
        var windowName = 'Print' + uniqueName.getTime();
        var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');

        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();
        printWindow.close();
    }

which does print the content of the GRID but it prompts user to select the printer.
I want the bill to be printed immediately on button click through the default printer.
Posted

I'm really happy that this is not possible! Just imagine how the web could be if you could start someones printer with no confirmation!
 
Share this answer
 

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