gridview 인쇄
2494 단어 JavaScripthtmlWebasp
코드 가 이 렇 습 니 다.
<html>
<head>
<script type="text/javascript" language="javascript">
function printPage() {
var newWin = window.open('printer.html','','');
var titleHTML = document.getElementById("printdiv").innerHTML;
newWin.document.write(titleHTML);
newWin.document.location.reload();
newWin.print();
newWin.close();
}
</script>
</head>
<body>
<div id="printdiv">
<table class="sontable" cellspacing="0" cellpadding="0" style="width: 13%">
<tr>
<td style="width: 700px; height: 161px">
<asp:GridView ID="GridData" runat="server" CellPadding="3" CellSpacing="0" BorderWidth="1px" BackColor="LightSteelBlue" BorderColor="White" BorderStyle="None" Font-Size="12px" Width="543px" Height="20px" OnRowDataBound="GridData_RowDataBound">
<RowStyle BackColor="GhostWhite" BorderColor="#006699" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" Wrap="True" />
<HeaderStyle Height="25px" BackColor="#006699" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" CssClass="Freezing"/>
</asp:GridView>
</td>
</tr>
</table>
</div>
<a href="javascript:;" onclick="printPage()"> </a>
</body>
</html>
이 원 리 는 GridView 의 내용 을 다른 웹 페이지 에 넣 고 인쇄 하 는 것 입 니 다!두 번 째 방법 은 인쇄 할 탭 을 제외 하고 페이지 에 있 는 탭 을 숨 기 고 인쇄 를 실행 하 는 것 입 니 다. 인쇄 후 페이지 에 있 는 탭 을 모두 표시 하 는 코드 는 다음 과 같 습 니 다: function printer () { beforeprint(); window.focus(); window.print() afterprint();}function beforeprint(){ for(i = 0; i < document.all.length; i++) { if ((document. all (i). id. index Of ("div table")! = - 1) & & & document. all (i). tagName = = "TABLE") / / 그 중 "div table" 인쇄 할 태그 ID 를 검사 합 니 다 { document.all(i).style.display="none"; } }}function afterprint(){ for(i = 0; i < document.all.length; i++) { if ((document.all(i).id.indexOf("div_table_")!=-1) && document.all(i).tagName=="TABLE") { document.all(i).style.display="block"; } }}printer () 를 호출 하면 됩 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.