<head runat="server">
<title>未命名頁面</title>
<script type="text/javascript">
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var strOldOne=prtContent.innerHTML;
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>
</head>
<div id="divPrint"> //用DIV將GridView包含起來,並給予一個名稱
<asp:GridView ID="GV" runat="server" Style="position: static" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal">
...........................................
</asp:GridView>
</div>
//增加列印按鈕
Button1.Attributes.Add("onClick","CallPrint('divPrint');");
留言列表