Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
i have a problem that I want to print a money receipt which I have shown through a .aspx page. But when I print it through browser print then it differ from browser to browser and I have to set the header and footer .

How Can I use it dynamically by taking a print button by which I can set my page according to the printer.

Please help me.

Thanks.
Posted

Hi,

If you are showing the reciept in a seperate aspx page with a print button and the window screenshot can do your work,i guess this should do it for you.


<asp:button id="btnPrintbtn" runat="server" onclick="window.print();" xmlns:asp="#unknown">


check these links below for custom printing

http://forums.asp.net/t/1638803.aspx
Creating print preview page dynamically in ASP.NET
http://asp.net.bigresource.com/Web-Forms-how-to-print-option-on-webpage-raUffMfhf.html

Hope this helps.
 
Share this answer
 
v3
You can design the receipt using ssrs or any other reporting services and get the print done.
 
Share this answer
 
Just use "window.print()". It's a javascript function.
 
Share this answer
 
Ok, if you don't want to use JS functions then Use below process:

Process 1:

C#
#region PrintLogicNew
            string fileName = System.IO.Path.GetFileName(Request.Path).Substring(0, System.IO.Path.GetFileName(Request.Path).Length - 5);
            Utilities.Common obj_Common = new Utilities.Common();
            hdfPrintCacheId.Value = fileName + Session.SessionID + "Print";
            Cache.Insert(hdfPrintCacheId.Value, dvPrint, null, DateTime.MaxValue, TimeSpan.FromMinutes(Convert.ToDouble(ConfigurationSettings.AppSettings["CacheExpiryTime"])));
            #endregion


Process 2:

At HTML Page

ASP.NET
<asp:hiddenfield id="hdfPrintCacheId" runat="server" xmlns:asp="#unknown" />
                                                                    <a href="#" onclick="JavaScript:openPrintWindowWithQueryString('<%=hdfPrintCacheId.Value %>');">
                                        <img src="../Images/print.gif" style="border: none" /></a>


Above process will help you. :-D
 
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