我页面上有绑定个产品图片的!现在要把它打印出来的!只打印这张产品图片的!请问要怎么写啊!

解决方案 »

  1.   

    你可以这样啊
    <%@ Page Language="C#" %><!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>
    </head>
    <body>
      <form id="form1" runat="server">
      其他内容
      <img src="http://dotnet.aspx.cc/Images/logoSite.gif" id="x" />
      <input type="button" onclick="p()" value="print" />
      <script>
        function p() {
          document.getElementById("<%=form1.ClientID %>").style.display = "none"
          d = document.createElement("div")
          d.innerHTML = "<img src=" + document.getElementById("x").src + " />"
          d.style.display = ""
          document.body.appendChild(d)
          window.print();
          document.getElementById("<%=form1.ClientID %>").style.display = ""
          d.parentNode.removeChild(d);
        }
      </script>
      </form>
    </body>
    </html>