欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【经典ASP.NET打印技术】,下面是详细的分享!
经典ASP.NET打印技术
〈%@ Page language="c#" Codebehind="WebExample.aspx.cs" AutoEventWireup="false" Inherits="WebPrint.WebExample" %>
〈!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
〈HTML>
〈HEAD>
〈title>一个简单的ScriptX打印〈/title>
〈meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
〈meta name="CODE_LANGUAGE" Content="C#">
〈meta name="vs_defaultClientScript" content="JavaScript">
〈meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
〈LINK href=http://www.chinaz.com/program/2008/1125/"kg.css" type="text/css" rel="stylesheet">
〈/HEAD>
〈body MS_POSITIONING="GridLayout">
〈form id="WebExample" method="post" runat="server">
〈TABLE width="100%" height="100%">
〈tr>
〈td height="100">
〈/td>
〈/tr>
〈tr>
〈td style="HEIGHT: 14px" align="center">
〈div id="divTableResult" name="divTableResult">
〈asp:Label id="Label1" runat="server" Width="232px" Height="32px" Font-Size="Large">欢迎使用ScriptX打印〈/asp:Label>
〈/div>
〈/td>
〈/tr>
〈tr>
〈td align="center" valign="top">
〈div id="divChartResult" name="divChartResult">
〈asp:Image id="Image1" runat="server" ImageUrl="win2000.gif">〈/asp:Image>
〈/div>
〈/td>
〈/tr>
〈tr>
〈td align="center" valign="top">
〈input id="btnPrint" style="WIDTH: 32px; HEIGHT: 19px" onclick="printResult();" type="button"
size="1" value="打印" name="btnPrint">
〈/td>
〈/tr>
〈/TABLE>
〈/form>
〈script language="javascript">
function printResult()
{
//针对不同模块,设置打印参数
var title='ScriptX打印';//报表名称
var orien='true';//打印页面方向,true:纵向打印/false横向打印
//参数设置结束
var strURL;
title=escape(title);
//condition=escape(condition);
strURL='printContainer2.aspx?title='+title+'&orien='+orien;
window.open(strURL,'printResult','height=600, width=800, top=0, left=50,toolbar=no , menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}
〈/script>
〈/body>
〈/HTML>
〈html>
〈head>
〈title>ScriptX 打印〈/title>
〈meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
〈meta name="CODE_LANGUAGE" Content="C#">
〈meta name="vs_defaultClientScript" content="JavaScript">
〈meta http-equiv="content-type" content="text/html; charset=gb2312">
〈meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
〈link href=http://www.chinaz.com/program/2008/1125/"kg.css" rel="stylesheet" type="text/css">
〈link href=http://www.chinaz.com/program/2008/1125/"print.css" rel="stylesheet" type="text/css" media="print" >
〈script FOR=document event="onclick">
if(event.srcElement.tagName=='A'){
//alert('a click!');
event.cancelBubble=true;
}
〈/script>
〈style type="text/css">
a:link {text-decoration:none}
a:visited {text-decoration:none}
a:active {text-decoration:none}
a:hover {text-decoration:none}
A { COLOR: #000000;TEXT-DECORATION: none; FONT-SIZE: 8pt;FONT-FAMILY: "";}
〈/style>
〈/head>
〈body MS_POSITIONING="GridLayout" >
〈!--这里调用控件ScriptX.cab-->
〈object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="ScriptX.cab#Version=6,1,431,2">
〈/object>
〈SCRIPT defer>
//用于设置打印参数
function printBase() {
factory.printing.footer="&b ScriptX 打印 &b" //页眉
factory.printing.footer="" //页脚
factory.printing.portrait=〈%=orientation%> //true为纵向打印,flase为横向打印
factory.printing.leftMargin=1.5 //左页边距
factory.printing.topMargin=0.5 //上页边距
factory.printing.rightMargin=0.5 //右页边距
factory.printing.bottomMargin=1.0 //下页边距
}
〈/SCRIPT>
〈table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#FFFFFF">
〈tr bordercolor="#FFFFFF">
〈td >
〈table width="70%" border="0" cellspacing="0" cellpadding="2" align="center">
〈tr>
〈td align="center">〈font size="5" face="宋体">〈b>〈div name="divTitle" id="divTitle">〈/div>〈/b>〈/font>〈/td>
〈/tr>
〈tr>
〈td align="center">
〈div id="divReport" name="divReport">
〈input type="button" name="cmdPRINT" id="cmdPRINT" onclick="printReport()" value="打印">
〈input type="button" onclick="window.close();" value="关闭">
〈/div>
〈/td>
〈/tr>
〈/table>
〈/td>
〈/tr>
〈/table>
〈table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
〈tr>〈td align="center">
〈!-- 用于显示divTableContainer标签的值 -->
〈div id="divTableContainer" name="divTableContainer">〈/div>
〈/td>〈/tr>
〈tr>〈td align="center">
〈!-- 用于显示divChartContainer标签的值 -->
〈div id="divChartContainer" name="divChartContainer">〈/div>
〈/td>〈/tr>
〈/table>
〈/body>
〈script language="javascript">
//使界面最大化
maxWin();
var needcon='';
document.all.divTitle.innerText=unescape('〈%=title%>');
//用于把父窗体的divTableResult和divChartResult标签的值分别转入divTableContainer 和divChartContainer标签中
var tableContent=window.opener.document.all.divTableResult.innerHTML;
tableContent=replaceAll(tableContent,"〈A ","〈span ");
tableContent=replaceAll(tableContent,"〈/A> ","〈/span> ");
tableContent=replaceAll(tableContent,"〈a ","〈span ");
tableContent=replaceAll(tableContent,"〈/a> ","〈/span> ");
tableContent=replaceAll(tableContent,"〈input ","〈font ");
tableContent=replaceAll(tableContent,"〈INPUT ","〈font ");
document.all.divTableContainer.innerHTML=tableContent;
document.all.divChartContainer.innerHTML=window.opener.document.all.divChartResult.innerHTML;
//用于调用设置打印参数的方法和显示预览界面
function printReport(){
printBase();
//window.print();
factory.printing.Preview();
}
function replaceAll( str, from, to ) {
var idx=str.indexOf( from );
while ( idx > -1 ) {
str=str.replace( from, to );
idx=str.indexOf( from );
}
return str;
}
function maxWin()
{
var aw=screen.availWidth;
var ah=screen.availHeight;
window.moveTo(0, 0);
window.resizeTo(aw, ah);
}
〈/script>
〈/html>
以上所分享的是关于经典ASP.NET打印技术,下面是编辑为你推荐的有价值的用户互动:
相关问题:asp.net 打印
答: 打印的区域或内容 打印 实现打印的JS函数: //局部打印 function printView(id) { var sprnhtml = $(id).outerHTML; var selfhtml = window.document.body.innerHTML;//获取当前页的html window.document.body.innerHTML = sprnhtml; window.pri... >>详细
相关问题:asp.net打印问题(word)
答:这个很简单的。 在网页上显示Word文档的名称,Word文件放在服务器的某个目录。 当用户点击打印的时候,直接在服务器上把Word打印到指定的打印机上。 当然Word的操作要在Project中把Word.dll引用进来。 调用word的组件的print的方法。这个具体的... >>详细
相关问题:求在ASP.NET中实现 打印功能代码
答:利用div标签,将待打印的内容放在div标签里,执行局部打樱示例代码: function printdiv(printpage) { var headstr = " "; var footstr = " "; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; do... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
