javascript 打印 asp.net

<div id='studentPhoTable'>
                <table class="table table-border table-bordered table-hover table-bg table-sort">
                    <tbody>
                        <asp:Repeater ID="rptlist" runat="server">
                            <ItemTemplate>
                                <tr>
                                    <td colspan="4" style="padding-top: 66px;"></td>
                                </tr>
                                <tr>
                                    <td colspan="4" align="center">
                                        <h1><strong>交货单</strong><strong></strong></h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">社区:<%#Eval("xiaoqu_name") %></td>
                                    <td colspan="2">商品数量:<%#Eval("pcount")%></td>
                                </tr>
                                <tr>
                                    <td colspan="2">团长姓名:<%#Eval("name") %></td>
                                    <td colspan="2">团长电话:<%#Eval("mobilePhone") %></td>
                                </tr>
                                <tr>
                                    <td colspan="4">地址:<%#Eval("address") %></td>
                                </tr>

                                <tr>
                                    <td><strong>序号</strong></td>
                                    <td><strong>商品分类</strong></td>
                                    <td><strong>商品名称</strong></td>
                                    <td><strong>数量</strong></td>
                                </tr>
                                <asp:Repeater ID="rpta" runat="server">
                                    <ItemTemplate>
                                        <tr>
                                            <td><%#Container.ItemIndex+1 %></td>
                                            <td><%#Eval("fenLei_name") %></td>
                                            <td><%#Eval("product_Name") %></td>
                                            <td><%#Eval("procount") %></td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
            </div>

 <input type="button" οnclick="print()" value="确定打印" class="btn btn-primary radius" />

 

<script type="text/javascript">
        function print() {

            var divToPrint = document.getElementById('studentPhoTable');
            var htmlToPrint = '' +
                  '<style type="text/css">' +
                'table {' +
                'border-right:1px solid #000;' +
                'border-bottom:1px solid #000;' +
                  ' width:700px;' +              //控制打开在A4纸上的宽度
                '}' +
                'table td{' +
                    'border-left:1px solid #000;' +
                    'border-top:1px solid #000' +
                '}' +
                '#box > table:nth-child(3){' +
                    'width:1505px;' +
                    'height:143px;' +
                    'margin-bottom: 20px;' +
                '}' +
                '#box > table:nth-child(4){' +
                    'width:1505px;' +
                    'height:143px;' +
                    'margin-bottom: 20px;' +
                '}' +
                '#box > table:nth-child(5){' +
                    'width:1505px;' +
                    'height:143px;' +
                    'margin-bottom: 20px;' +
                '}' +
                '#box > table:nth-child(6){' +
                    'width:1505px;' +
                    'height:143px;' +
                    'margin-bottom: 20px;' +
                '}' +
                '#box > p.text-center > span{' +
                    'position: relative;' +
                    'left: 50%;' +
                '}' +
                '#box > p.clearfix.order-title > span.pull-left.order-num{' +
                    'position: relative;' +
                    'right: -78%;' +
                '}' +
                '#box > p.clearfix.order-title > span.pull-left.partment{' +
                    'position: relative;' +
                    'left: 2%;' +
                '}' +
            '</style>';
            htmlToPrint += divToPrint.outerHTML;
            newWin = window.open("");
            newWin.document.write(htmlToPrint);
            newWin.print();
            newWin.close();
        }
    </script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值