摘要:[ASP.NET] 利用JavaScript列印GridView內容
之前小弟做了頁面列印
但是收到USER希望只要列印GridView內容即可
所以小弟改了一下...多多指教
<!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>GridView列印</title>
<script language="javascript" type="text/javascript">
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var strOldOne = prtContent.innerHTML;
var WinPrint = window.open();
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = strOldOne;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="GridView列印" onclick="CallPrint('divPrint');" />
<br />
<div id="divPrint">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</div>
</form>
</body>
</html>
開啟只有GridView內容的新視窗,並且呼叫列印
Y2J's Life:http://kimenyeh.blogspot.tw/