• web 打印 webrower 控件的ExecWB 及 兼容IE6 IE7 IE8 打印 办法 Kenny


    话不多说,先把代码附上吧

    代码
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PrintOrder.aspx.cs" Inherits="SalesOrder_PrintOrder" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>打印商品发货单</title>
    <style type="text/css">
    body,table { font
    -family: Arial, Helvetica, sans-serif; font-size: 14px; }
    .btn{display:none;}
    .STYLE1 {font
    -size: 18px;font-weight: bold;}
    </style>
    <style media="print" type="text/css">
    .Noprint{display:none;}
    .PageNext{page
    -break-after: always;}


    </style>


    </head>
    <body>
    <form id="form1" runat="server">
    <object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WebBrowser" width="0"></object>
    <input name="Button" onclick="document.all.WebBrowser.ExecWB(7,1);document.getElementById('btnPrint').click();" class="Noprint" type="button" value="打印并预览" id="Button1" />
    <asp:Button ID="btnPrint" runat="server" Text="Button" OnClick="btnPrint_Click" CssClass="btn" /><asp:HiddenField ID="HFPrint" runat="server" /> <a onclick="window.close()">关闭</a>

    <table width="800" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td style=" 500px;54; height:50;">
    <h1>
    <b><center>商品发货单</center></b></h1>
    </td>
    <td colspan="4">
    ||||||||||||||||||||||||||||||||||||||||||||
    <br />
    灵德订单:
    <asp:Label ID="lblLDID" runat="server" ></asp:Label>
    </td>
    </tr>
    <tr>
    <td style="height:35;" colspan="5">
    <span class="STYLE1">收件人信息</span></td>
    </tr>
    <tr>
    <td height="120" colspan="5" align="left" valign="top">
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td style="60px;">
    订购平台
    </td>
    <td style="140px;" align="center">
    <asp:Label ID="lblBuyChannel" runat="server" ></asp:Label></td>
    <td style="60px;">
    平台ID
    </td>
    <td align="center" style="140px;">
    <asp:Label ID="lblBuyChannelID" runat="server" ></asp:Label></td>
    </tr>
    <tr>
    <td style="60px;">
    交易时间
    </td>
    <td align="center" style="140px;">
    <asp:Label ID="lblTradeTime" runat="server" ></asp:Label></td>
    <td style="60px;">
    收件人
    </td>
    <td align="center" style="140px;">
    <asp:Label ID="lblSJR" runat="server" ></asp:Label></td>
    </tr>
    <tr>
    <td style="60px;">
    送货省市
    </td>
    <td align="center" style="140px;">
    <asp:Label ID="lblDelvCity" runat="server" ></asp:Label></td>
    <td style="60px;">
    受理客服
    </td>
    <td align="center" style="140px;">
    <asp:Label ID="lblClerk" runat="server" ></asp:Label></td>
    </tr>
    <tr>
    <td rowspan="3">客服备注</td>
    <td rowspan="3">&nbsp;<asp:Label ID="lblClerkRemark" runat="server" ></asp:Label></td>
    <td >顾客备注</td>
    <td >&nbsp;<asp:Label ID="lblBuyerRemark" runat="server" ></asp:Label></td>
    </tr>
    <tr>

    <td style="60px;">
    售后电话
    </td>
    <td align="center" style="120px;">
    <asp:Label ID="lblSalesTel" runat="server" Text="137 6133 2393" ></asp:Label></td>
    </tr>
    <tr>
    <td style="60px;">
    售后服务
    </td>
    <td align="center" style="120px;">
    <asp:Label ID="lblSalesNet" runat="server" Text="www.shushome.com" ></asp:Label></td>
    </tr>
    </table>
    </td>
    </tr>

    </table>
    </form>
    </body>
    </html>


    关键代码
    document.all.WebBrowser.ExecWB(7,1);//其他的可以google

    如果在IE6,IE7,IE8中不能调出打印的话可以尝试修改客户端的设置
    这点很重要哟:
    菜单->工具->Internet选项->安全->把internet和本地internet的自定义级别-> 把 “对未标记为安全执行脚本的ActiveX控件初始化...”设置为启用或者提示
    为了提高安全性,微软把IE7,8的这个选项给设成禁用!所以手动设置重启下浏览器就可以用了,

  • 相关阅读:
    Qt Installer Framework翻译(7-0)
    Qt Installer Framework翻译(4)
    Qt Installer Framework翻译(6-0)
    Qt Installer Framework翻译(5-4)
    Qt Installer Framework翻译(5-3)
    Qt Installer Framework翻译(5-2)
    Qt Installer Framework翻译(5-1)
    Qt Installer Framework翻译(5-0)
    Qt Installer Framework翻译(3-5)
    angularjs1.X进阶笔记(3)——如何重构controller
  • 原文地址:https://www.cnblogs.com/chenhuzi/p/1688218.html
Copyright © 2020-2023  润新知