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

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.

Test.aspx:

<%@ 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");
    }
</script>
<html>
<head>
    <title>Test Form</title>
</head>
<body>
    <form runat="server">
        <table>
            <tbody>
                <tr>
                    <td colspan="2">
                        <strong>Test Form</strong></td>
                </tr>
                <tr>
                    <td>
                        First&nbsp;Name</td>
                    <td>
                        <asp:TextBox id="FirstName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Last&nbsp;Name</td>
                    <td>
                        <asp:TextBox id="LastName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button id="Submit" onclick="Submit_Click" 
                              runat="server" Text="Submit"></asp:Button>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>


View Entire Article

User Comments

No comments posted yet.






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


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-03-24 5:50:03 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search