Click here to Skip to main content
11,414,670 members (70,604 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I am doing Restarunt project. I want to print Bill when i click the button onthe webpage.Please any simple idea for print. Thank you

I am using Asp.net with C#
Posted 21-Mar-12 1:37am
devausha1.4K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
devausha at 21-Mar-12 7:43am
   
I want print text to notepad dynamically and then send file to printer
Member 8763905 at 12-Mar-13 7:02am
   
I have one .aspx page from which I want to print some part
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

use this script 
1)
<script language="javascript" type="text/javascript">
    function CallPrint(strid) {
        var prtContent = document.getElementById(strid);
        var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(prtContent.innerHTML);
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();
        prtContent.innerHTML = strOldOne;
    }
</script>
2)
<div id ="bill">
<%-- the content will be printed --%>.

3)call the Function 

<asp:button id="BtnPrint" runat="server" text="Print" onclientclick="javascript:CallPrint('bill');" xmlns:asp="#unknown" />
</div>
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this code
<asp:Button ID="printButton" runat="server" Text="Print" OnClientClick="javascript:window.print();" />
  Permalink  
Comments
devausha at 21-Mar-12 6:46am
   
I want to creating Bill format at runtime like prn file and then that file is printed. How to do it.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

function printwindow()
      {
       document .getElementById('<%=lnkprint.ClientID%>').style.visibility= "hidden";
       document .getElementById('<%=lnkExport.ClientID%>').style.visibility= "hidden";
 
       window.print();
       document .getElementById('<%=lnkprint.ClientID%>').style.visibility= "visible";
       document .getElementById('<%=lnkExport.ClientID%>').style.visibility= "visible";
 

      }

<asp:linkbutton id="lnkprint" runat="server" text="Print" onclientclick="printwindow();"
                            ForeColor="Blue" />
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

try this link
Custom print
  Permalink  
Comments
kareem salem at 21-Mar-12 7:05am
   
or this

http://www.eggheadcafe.com/tutorials/asp-net/ed88bcef-0f0e-415c-9674-763806da1f43/print-web-page-in-aspnet-20.aspx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

I suppose you want to print only a part of the page.
I would suggest to put your control in a pannel.
Following is the code.
<script type="text/javascript">
    function PrintTextbox() {
        var text_box = document.getElementById("<%=Panel1.ClientID %>");
        var printWindow = window.open('', '', 'height=400,width=800');
        printWindow.document.write('<html><head><title>Name of File</title>');
        printWindow.document.write('</head><body >');
        printWindow.document.write(text_box.innerHTML);
        printWindow.document.write('</body></html>');
        printWindow.document.close();
        setTimeout(function () {
            printWindow.print();
        }, 500);
        return false;
    }
    </script></script>

Hope this helps..
  Permalink  
Comments
CHill60 at 30-Mar-14 11:58am
   
You are two years and 6 solutions late on this one
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

If your printer supports ESC/POS (EPSON printer lang) then you can directly print to the client printer from your ASP.NET page by following this code or this other one. The first one is not free and requires you install an utility at the client machine. The second one, is open source and limited to community mail list support (or you can pay for personal support) and requires JAVA VM installed at the client machine.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,130
1 OriginalGriff 7,477
2 Maciej Los 3,710
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web02 | 2.8.150427.4 | Last Updated 31 Mar 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100