ASP.NET打印功能實現
<head runat="server">
<title>无标题页</title>
<script language="Javascript" type="text/javascript">
function preview()
{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<center>本部分以上不被打印</center>
<!--startprint-->
<div align="center">
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</div>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="打印" onclick="preview()"/>
</div>
sdfsfsdfsdfsdfsdfsdf
sdfsdfsdfsdfsdfsdfsd
sfsfsdfsd
<input class="Noprn" type="button" onclick="window.print()" value="print"/>
</form>
</body>
</html>