So, what I'm attempting to do is this:
I built a web form (.aspx) using c# and it will be used as an order form of sorts for one of our departments. What I'm trying to do is to set up a "Submit" button that when clicked on, sends this document, or web form, to a printer on our network, along with having the information extracted, and inserted into a database that I've already built and sits on a sql server.
Again, I know squat about coding and have looked everywhere. I'm extremely confused and pretty much frustrated.
Please help. I'll answer any questions :)
Thank you in advance.
Here's my .cs code:
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Data;
- using System.Configuration;
- using System.Management;
- using System.Drawing;
- using System.Drawing.Printing;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Web.SessionState;
- using System.Windows.Forms;
- public partial class ShopFillForm : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- int OrderID = 0;
- l_Date.Text = DateTime.Now.ToString("MM-dd-yy hh:mm");
- }
- protected void b_submit_Click(object sender, EventArgs e)
- {
- // Event handler code
- PrintDocument doc = new PrintDocument();
- doc.PrinterSettings.PrinterName = "PRINTER on SERVER";
- doc.PrintPage += new PrintPageEventHandler(this.b_submit_Click);
- doc.Print();
- }
- }
- And here's what I've got on the document regarding the submit/print button:
- <asp:Button id="b_submit" runat="server" Text="Submit" style="text-align: center"
- onclick="b_submit_Click" />
- If I'm doing something wrong or missing something, please let me know.
- When I click submit, it shows that its trying to do something, but it goes to error.
- Here is the error:
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
- Exception Details: System.Drawing.Printing.InvalidPrinterException: Settings to access printer 'UPCOLOR on print.pdxftl.com' are not valid.
- Source Error:
- Line 32: doc.PrinterSettings.PrinterName = "UPCOLOR on print.pdxftl.com";
- Line 33: doc.PrintPage += new PrintPageEventHandler(this.b_submit_Click);
- Line 34: doc.Print();
- Line 35: }
- Line 36: }
- Source File: y:\ShopFillForm.aspx.cs Line: 34
- Stack Trace:
- [InvalidPrinterException: Settings to access printer 'UPCOLOR on print.pdxftl.com' are not valid.]
- System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(String printer) +199360
- System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal() +28
- System.Drawing.Printing.PrinterSettings.GetHdevmode(PageSettings pageSettings) +48
- System.Drawing.Printing.PrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) +71
- System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e) +30
- System.Drawing.Printing.PrintController.Print(PrintDocument document) +208
- System.Drawing.Printing.PrintDocument.Print() +111
- ShopFillForm.b_submit_Click(Object sender, EventArgs e) in y:\ShopFillForm.aspx.cs:34
- System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9752490
- System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +196
- System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
- System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
- System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
- System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724