Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this print content form contain of data gridvew and a div act like a textbox

i want for the user to be able to print the form after he edit the textbox with new text


XML
<%@ Page Title="" Language="C#" MasterPageFile="~/MembersOnly/Hiring/MasterPageHiring.master" AutoEventWireup="true" CodeFile="FormatedQuotPreview.aspx.cs" Inherits="MembersOnly_Hiring_Quotation_FormatedQuotPreview" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <style type="text/css">
        .style1 {
            width: 97%;
        }
        #printContent:before ,#printContent:after{
            content:none;
        }
        /*#TextBox1 {
    width: 300px;
    height: 200px;
    border: 1px solid #ccc;
    padding: 5px;
}*/
        .style2 {
        }

        .style3 {
        }

        .style4 {
            width: 175px;
        }

        .style5 {
        }

        .style7 {
            text-decoration: underline;
        }

        .style8 {
            width: 99%;
            direction: ltr;
        }

        .style9 {
        }

        .style10 {
            height: 20px;
        }

        .style11 {
            width: 220px;
        }

        .style12 {
            width: 98px;
            font-weight: bold;
        }

        .style14 {
            width: 97px;
        }

        .style15 {
            width: 597px;
        }

        .auto-style1 {
            width: 409px;
            height: 50px;
            direction: ltr;
        }

        .auto-style2 {
            width: 95px;
            height: 50px;
            direction: ltr;
        }

        .auto-style3 {
            height: 50px;
        }

        .button_small {
            direction: ltr;
        }

        .auto-style4 {
            width: 897px;
        }

        .auto-style5 {
            width: 15px;
        }

        .auto-style7 {
            width: 1056px;
        }

        .auto-style8 {
            width: 343px;
        }

        .auto-style9 {
            width: 277px;
        }
        .auto-style10 {
            height: 128px;
        }
        .auto-style11 {
            width: 485px;
        }
        .auto-style12 {
            width: 69px;
            font-weight: bold;
        }
        .auto-style13 {
            width: 69px;
        }
        .auto-style14 {
            width: 974px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <table class="style1">
        <tr>
            <td class="auto-style14">
                <b>
                    <asp:HyperLink ID="HyperLinkHM" runat="server"
                        NavigateUrl="~/MembersOnly/Home/Home.aspx">Home</asp:HyperLink>
                    <strong>&nbsp;</strong>&gt;
        <asp:HyperLink ID="hiringHomeHyperLink" runat="server"
            NavigateUrl="~/MembersOnly/Hiring/HiringHome.aspx">Hiring</asp:HyperLink>
                    &nbsp;&gt; Invoices</b></td>
        </tr>

        <tr>
            <td class="auto-style14">
                <asp:Label ID="lblTitle" runat="server" CssClass="titleLabel"
                    Text="Hiring Quotations"></asp:Label></td>
        </tr>

        <tr>
            <td class="auto-style14">&nbsp;</td>
        </tr>

        <tr>
            <td class="auto-style14">
                    <asp:Panel ID="searchPanel" runat="server" CssClass="inputPanel">
                        <table class="style1">
                            <tr>
                                <td class="style11">&nbsp;</td>
                                <td class="style4">&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style11">Quotation Refrence Number</td>
                                <td class="style4">
                                    <asp:TextBox ID="txtReference" runat="server"></asp:TextBox>
                                    <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1"
                                        runat="server" CompletionInterval="10" CompletionSetCount="12"
                                        DelimiterCharacters="" EnableCaching="true" Enabled="True"
                                        FirstRowSelected="True" MinimumPrefixLength="1"
                                        ServiceMethod="GetCompletionList"
                                        ServicePath="~/MembersOnly/WebServices/QutationRefr.asmx"
                                        TargetControlID="txtReference" UseContextKey="true">
                                    </ajaxToolkit:AutoCompleteExtender>
                                </td>
                                <td>
                                    <asp:Button ID="btnPreview" runat="server" CssClass="btn" Text="Preview"
                                        OnClick="btnPreview_Click" />
                                </td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style11">&nbsp;</td>
                                <td class="style4">&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </asp:Panel>
            </td>
        </tr>

        <tr>
            <td class="auto-style14">
                <strong __designer:mapid="181">
                    <table class="style8" __designer:mapid="390">
                        <tr __designer:mapid="38c">
                            <td class="auto-style1" __designer:mapid="38d"></td>
                            <td class="auto-style2" __designer:mapid="393">
                                <asp:Button ID="btnPrint" runat="server" CssClass="btn" OnClick="btnPrint_Click" OnClientClick="return PrintPanel();" Text="Print" Visible="True" Width="123px" Height="34px" />
                            </td>
                            <td class="auto-style3" __designer:mapid="395"></td>
                        </tr>
                    </table>
                </strong>
            </td>
        </tr>

        <tr>
            <td class="auto-style14">
                <div id="printContent">
                <asp:Panel runat="server" ID="QuotePanel" Width="990px">

                    <table class="style1">
                        <tr>
                            <td style="text-align: center">
                                <br />
                                <br />
                                <br />
                                <br />
                            </td>
                            <td style="text-align: center">&nbsp;</td>
                        </tr>
                        <tr>
                            <td>Ref. No:
                <asp:Label ID="lblReference" runat="server"></asp:Label>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RFQ. No:</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style10">Dated:
                <asp:Label ID="lblDate" runat="server"></asp:Label>
                            </td>
                            <td class="style10">&nbsp;</td>
                        </tr>
                        <tr>
                            <td>M/S:
                <asp:Label ID="lblCustomerName" runat="server"></asp:Label>
                            </td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td>
                                Address:
                                <asp:Label ID="lblAddress" runat="server"></asp:Label>
                                <td>&nbsp;<td></td>
                                </td>
                            </td>

                        </tr>
                        <tr>
                            <td>
                                <table class="style1">
                                    <tr>
                                        <td>✆ Tel:
                            <asp:Label ID="lblTel" runat="server"></asp:Label>
                                        </td>
                                        <td>☏ Fax:
                                            <asp:Label ID="lblFax" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>✆ Supervisor Tel:
                            <asp:Label ID="lblSupervisor" runat="server"></asp:Label>
                                        </td>
                                        <td>✉ Email:
                                            <asp:Label ID="lblEmail" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            <br />
                                            <table class="style1">
                                                <tr>
                                                    <td class="style2" colspan="3">
                                                        <b><u>Sub: Quotation for hiring of heavy equipment<br /> </u></b></td>
                                                    <caption>
                                                        <br />
                                                    </caption>
                                                </tr>
                                                <caption>
                                                    <br />
                                                    <tr>
                                                        <td class="style3" colspan="3">We thank you for your interest in our organization and glad to quote our best prices for the below mentioned item<asp:Label ID="lblS" runat="server" Text="s" Visible="False"></asp:Label>
                                                            .</td>
                                                    </tr>
                                                </caption>
                                            </table>
                                            <table class="style1">
                                                <tr>

                                                    <td class="auto-style10" colspan="3">
                                                        <asp:GridView ID="gvwQoute" runat="server" Width="106%" style="margin-right: 18px">
                                                            <HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" />
                                                        </asp:GridView>
                                                        <div style="width: 800px">
                                                            </div>



                                                         <tr>
                            <td class="auto-style13">
                                &nbsp;</td>
                            <td class="auto-style11">
                                &nbsp;</td>
                            <td class="style9">
                                &nbsp;</td>
                            <td colspan="2">
                                &nbsp;</td>
                        </tr>

                                                                <tr>
                                                                    <td class="auto-style12" style="border: thin solid #000000">in Words</td>
                                                                    <td class="auto-style11" style="border: thin solid #000000">
                                                                        <asp:Label ID="lblWords" runat="server"></asp:Label>
                                                                    </td>

                                                                    <td class="style14" style="border: thin solid #000000"><b>Total BD</b></td>
                                                                    <td style="border: thin solid #000000">
                                                                        <asp:Label ID="lblTotal" runat="server"></asp:Label>
                                                                    </td>

                                                                </tr>
                                                                <tr>
                            <td class="auto-style13">
                                &nbsp;</td>
                            <td class="auto-style11">
                                &nbsp;</td>
                            <td class="style9">
                                &nbsp;</td>
                            <td colspan="2">
                                &nbsp;</td>
                        </tr>

                                                </tr>
                                            </table>
                                            <table class="style1">
                                                <tr>
                                                    <td class="auto-style4">
                                                        <br />
                                                        <div>
                                                            <div id="TextBox1" style="overflow: hidden; font-size: large; width: 894px;">
                                                                The price includes provision for fuel, operator, maintenance, mobilization and demobilization
                                                                <br />
                                                                * <u><b>Validity:</b></u> 15 days from the above date.<br /> * <u><b>Payment:</b></u> To be agreed
                                                                <br />
                                                                *<b>(i) <u>The minimum charge 8 hours a day.</u></b><br /> *<b>(ii) <u>Any overtime charges above 8 Hours will be prorate basis.</u></b><br /> * Works supervision including safety and security will be the responsibility of the customer.
                                                                <br />
                                                                * We will not be liable for any damages that many occur on site while performing the job.
                                                                <br />
                                                                * LPO is to be advanced before commencement of work.<br />
                                                                <br />
                                                                <br />
                                                                <br />
                                                                We are looking forward for your valuable confirmation for the above. Should you required any further<br /> assistance, please do not hesitate to contact the above mentioned numbers.<br />
                                                                <br />
                                                                Jones (Manager) <b>015555999</b><br />
                                                                Goerge ( General Manager ) <b>0111111055</b><br />
                                                                <br />
                                                                Thanking You<br />
                                                                <br />
                                                                Yours truly,<br />
                                                            </div>
                                                            <%--Width="978px" Font-Size="14" BorderColor="white" BorderStyle="None"--%>
                                                            <br />
                                                        </div>
                                                        <table class="style8">
                                                            <tr>
                                                                <td class="auto-style9">&nbsp;________________________<br /><br />(Sayed Mohammed Al Durazi)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                    <br />
                                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Manager</b>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                                                <strong>
                                                                <td class="auto-style7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td>
                                                                <td class="auto-style8">&nbsp;<span class="style7">Customer Acceptance
                                                                    <br />
                                                                    </span>&nbsp;<br /> Approved by:&nbsp;&nbsp;&nbsp; ______________________<br /> Signature :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ______________________<br /> Company Seal: ______________________</td>
                                                                </strong>
                                                            </tr>
                                                        </table>
                                                        <p>
                                                        </p>
                                                        <br />
                                                        <br />
                                                        <br />
                                                        <br />
                                                        <br />
                                                        <br />
                                                        <br />
                                                    </td>
                                                    <td class="auto-style5">&nbsp;</td>
                                                    <td class="style5">&nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td class="style5" colspan="3">&nbsp;</td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    </caption>
                                </table>
                            </td>
                            <td>&nbsp;</td>
                        </tr>
                    </table>

                    </td>
                    </tr>
                    </table>

                </asp:Panel>
                </div>

            </td>
        </tr>
    </table>
    <script type="text/javascript">
        TextBox1.contentEditable = true;

    </script>
</asp:Content>




public static void PrintWebControl(Control ControlToPrint)
    {
        StringWriter stringWrite = new StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
        if (ControlToPrint is WebControl)
        {
            Unit w = new Unit(100, UnitType.Percentage);
            ((WebControl)ControlToPrint).Width = w;
        }
        Page pg = new Page();
        pg.EnableEventValidation = false;
        HtmlForm frm = new HtmlForm();
        pg.Controls.Add(frm);
        frm.Attributes.Add("runat", "server");
        frm.Controls.Add(ControlToPrint);
        pg.DesignerInitialize();
        pg.RenderControl(htmlWrite);
        string strHTML = stringWrite.ToString();
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.Write(strHTML);
        HttpContext.Current.Response.Write("<script>window.print();</script>");
        HttpContext.Current.Response.End();

    }
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        Session["ctrl"] = QuotePanel;
       QuotePanel.Visible = true;
       Control ctrl = (Control)Session["ctrl"];
       PrintWebControl(ctrl);
        

    }
}
Posted
Comments
Member 11880863 13-Sep-15 6:35am    
؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900