Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
I have a billing printer & i have made an aspx page with the help of visual studio 2010 and sql server 2008.page has some textboxes and some labels and one print button.


i just want to print that aspx page... i dont want that print setup or print dialouge box ...is it possible in webform ?? please help me out..i'm in big trouble if possible then please give me the source code of button click..please


Thank you......
Posted
Updated 26-Nov-20 1:45am
Comments
Member 15003686 26-Nov-20 7:47am    
please provide the same in java script

Hello Vivek,

Could you please see the following link:
Printing Using C# - Changing the Page Settings[^]

I have taken following code from it.
Printing Without the Preview

To print to another printer, you have to use the standard print dialog. We can bring this up in much the same way, so add this method to PrintEngine:
C#
// ShowPrintDialog - display the print dialog...
public void ShowPrintDialog()
{
  // create and show...
  PrintDialog dialog = new PrintDialog();
  dialog.PrinterSettings = PrinterSettings;
  dialog.Document = this;
  if(dialog.ShowDialog() == DialogResult.OK)
  {
    // save the changes...
    PrinterSettings = dialog.PrinterSettings;

    // do the printing...
    Print();
  }
}

Again, if the user clicks OK we save the settings, but this time we also call Print to print directly to the configured printer. Add this event handler to Form1 to finish this off:
C#
private void cmdPrint_Click(object sender, System.EventArgs e)
{
  // print...
  _engine.ShowPrintDialog();
}
 
Share this answer
 
Comments
Suvabrata Roy 11-Jun-14 2:38am    
Vivek: was asking for his web form but your solution will work in desktop.
For Mozilla : http://forums.mozillazine.org/viewtopic.php?t=48336

Javascript Code:
it will work for IE
JavaScript
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object id="PrintCommandObject" width="0" height="0<br" mode="hold" />CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}
 
Share this answer
 
You should learn the command language your target printer supports (e.g. ESC/P, ZPL, EPL, etc) to get fast printing performance and then use any of these tools to print at client side without dialog or create one by yourself

qzprint[^]: free or paid options. requires JAVA VM at the client
WebClientPrint[^]: paid, requires jQuery & ASP.NET
 
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