Quantcast
Channel: Crystal Reports
Viewing all articles
Browse latest Browse all 1507

how to Print on client side in asp.net c#

$
0
0

i want to print on client side ,currently below mentioned code working on server ,where i published my application,when i am giving print from client side ,then print is coming on server printer but i want print on client printer not on server.

protected void btnprnt_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtqty.Text) > 0)
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("sp_Importlabelprint", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    //SqlDataAdapter adp = new SqlDataAdapter("select prdno,orderno,Codeitem,prdqty from probale", con);
                    //DataSet ds = new DataSet();
                    //adp.Fill(ds);

                    for (int i = 0; i < Convert.ToInt32(txtqty.Text); i++)
                    {
                        ReportDocument rpt = new ReportDocument();
                        rpt.FileName = Server.MapPath("~/Importlbprint.rpt");
                        rpt.SetDataSource(ds.Tables["Table"]); //DS is Dataset which you want to print

                        rpt.SetParameterValue("PageNo", i + 1);
                        rpt.SetParameterValue("TotalPage", Convert.ToInt32(txtqty.Text));
                        rpt.PrintToPrinter(1, false, 1, 1);
                    }
                    string url = "/lbimportprints.aspx?noc=" + txtqty.Text;
                    Page.ClientScript.RegisterStartupScript(
                 this.GetType(), "OpenWindow", "window.open('" + url + "','_newtab');", true);

                }

                catch (Exception ex) { }

            }
        }
    }


Viewing all articles
Browse latest Browse all 1507

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>