Hello,
I need to be able to print a report automatically on client's local printer( some printers are on the same network and some others are usb-connected) .
I don't want to open the report in viewer before printing.
Here's my code:
- protected void Print(object sender, EventArgs e)
- {
- ImageButton lnkRowSelection = (ImageButton)sender;
- ReportDocument cryRpt = new ReportDocument();
- string[] commandArgs = lnkRowSelection.CommandArgument.ToString().Split(new char[] { ',' });
- string idno = commandArgs[0];
- string company = commandArgs[1];
- try
- {
- if (lnkRowSelection.CommandArgument.ToString() == null)
- Response.Redirect("Default.aspx");
- else
- {
- if (company == "True")
- cryRpt.Load(Server.MapPath("~/Reports/rep1.rpt"));
- else
- cryRpt.Load(Server.MapPath("~/Reports/rep2.rpt"));
- if (lnkRowSelection.CommandArgument.ToString() != null)
- {
- cryRpt.SetParameterValue("@idno", idno);
- cryRpt.SetParameterValue("Office", agr.getOffice());
- cryRpt.PrintToPrinter(2, true, 1, 2);
- }
- }
- }
- catch (Exception ex) { appObj.myMessageBox(ex.Message); }
- }
Thank you in advance.
Chriz LPosted Nov 15, 2016, 6:48 AM
Amit GuptaPosted Nov 15, 2016, 3:43 AM
Chriz LPosted Nov 15, 2016, 1:03 AM
Amit GuptaPosted Nov 14, 2016, 12:18 PM
Chriz LPosted Nov 14, 2016, 8:49 AM
Amit GuptaPosted Nov 14, 2016, 8:38 AM