コード例 #1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            PrinterSetup pageSetup = new PrinterSetup();

            pageSetup._PrinterName = ddlPrinterName.SelectedValue;
            if (rbAllPages.Checked)
            {
                pageSetup.AllPages    = true;
                pageSetup.CurrentPage = false;
            }
            else if (rbCurrentPage.Checked)
            {
                pageSetup.AllPages    = false;
                pageSetup.CurrentPage = true;
            }
            else
            {
                pageSetup.FromPage    = Convert.ToInt32(txtFromPage.Text);
                pageSetup.ToPage      = Convert.ToInt32(txtToPage.Text);
                pageSetup.CurrentPage = false;
                pageSetup.AllPages    = false;
            }
            pageSetup.NoOfCopies = 1;
            PrinterSettings      = pageSetup;

            // a code to be run in client-side
            string scriptStr = "<script>window.close();</script>";

            // send the script to output stream
            ClientScript.RegisterClientScriptBlock(typeof(string), "closing", scriptStr);
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         PrinterSettings    = null;
         rbAllPages.Checked = true;
         GetAllPrinter();
     }
 }