Printing an ASP.NET Web Form When It Is Submitted
page 3 of 5
by Andrew Mooney
Average Rating: 
Views (Total / Last 10 Days): 56288/ 66

Making a Test Form

[Download Code]
The test page conatins a test form with two fields. Only two lines of code in the Submit_Click routine are needed to print the web form. You must change the printer name to one that is installed on your server. For local printers and printers that use IP printing just use the name in your printers folder (example: "HP 1200") For Novell network printing use the path (example: \\server\printer). You may have to add impersonation to your web.config file for Novell network printing. One other note, the submit button must have an id equal to "Submit" or it will also be printed.


<%@ Page Language="C#" %>
<%@ outputcache location="None" %>
<script runat="server">    
    void Submit_Click(object sender, EventArgs e) {
        CsXml.FormPrint.WebPrinting wp = new CsXml.FormPrint.WebPrinting();
        wp.PageCreate("HP 1200", "TEST FORM");
    <title>Test Form</title>
    <form runat="server">
                    <td colspan="2">
                        <strong>Test Form</strong></td>
                        <asp:TextBox id="FirstName" runat="server"></asp:TextBox>
                        <asp:TextBox id="LastName" runat="server"></asp:TextBox>
                    <td colspan="2">
                        <asp:Button id="Submit" onclick="Submit_Click" 
                              runat="server" Text="Submit"></asp:Button>

View Entire Article

User Comments

No comments posted yet.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-02-25 8:39:32 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search