您的位置:首页 > 编程语言 > ASP

asp.net 代码实现打印功能

2011-08-28 20:03 471 查看
一.在服务器端实现

1.这个是在本页面上的.cs文件里写的
if (resultInt > 0)
{
//清除验证码 ,显示执行结果,并转向新的地址
Session["YanZhengMa"] = "";
String caoCode = "if(confirm('提交成功,是否打印'))" +
"{" +
"window.location.href='printTKZ.aspx?type=BF&BMId=" + _flowidValue +"&bufeitime="+ _jfTimeValue +"&palJE="

+_shouXianValue + "&goTo=buFeiList.aspx';" +
"}" +
"else" +
"{" +
"window.location.href='buFeiList.aspx';" +
"}";

MessageBox.alert(Page, (object)caoCode);
}

2.在你想要的打印 printTKZ.aspx这个页面上写上

就可以了

二.在客户端实现

function doPrint() {
bdhtml=window.document.body.innerHTML;
sprnstr=" ";
eprnstr=" ";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
}

放在打印地方的开头
打印地方的结尾
打 印
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: