代碼實(shí)現(xiàn)打印功能(asp.net+javascript)
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 22:44:28
代碼實(shí)現(xiàn)打印功能(asp.net+javascript)
代碼實(shí)現(xiàn)打印功能(asp.net+javascript):一.在服務(wù)器端實(shí)現(xiàn) 1.這個(gè)是在本頁(yè)面上的.cs文件里寫的 代碼如下:if (resultInt > 0) { //清除驗(yàn)證碼 ,顯示執(zhí)行結(jié)果,并轉(zhuǎn)向新的地址 Session[YanZhengMa] = ; String caoCode = if(confirm('提交成功,是否打印')) +
導(dǎo)讀代碼實(shí)現(xiàn)打印功能(asp.net+javascript):一.在服務(wù)器端實(shí)現(xiàn) 1.這個(gè)是在本頁(yè)面上的.cs文件里寫的 代碼如下:if (resultInt > 0) { //清除驗(yàn)證碼 ,顯示執(zhí)行結(jié)果,并轉(zhuǎn)向新的地址 Session[YanZhengMa] = ; String caoCode = if(confirm('提交成功,是否打印')) +

一.在服務(wù)器端實(shí)現(xiàn)
1.這個(gè)是在本頁(yè)面上的.cs文件里寫的
代碼如下:
if (resultInt > 0)
{
//清除驗(yàn)證碼 ,顯示執(zhí)行結(jié)果,并轉(zhuǎn)向新的地址
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這個(gè)頁(yè)面上寫上
<body onload="vbscript:window.print()">
就可以了
二.在客戶端實(shí)現(xiàn)
代碼如下:
<script language="javascript">
function doPrint() {
bdhtml=window.document.body.innerHTML;
sprnstr=" <!--startprint-->";
eprnstr=" <!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
}
</script>
<!--startprint--> 放在打印地方的開頭
<!--endprint-->打印地方的結(jié)尾
<a href="javascript:;" onclick="doPrint()">打 印 </a>
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
代碼實(shí)現(xiàn)打印功能(asp.net+javascript)
代碼實(shí)現(xiàn)打印功能(asp.net+javascript):一.在服務(wù)器端實(shí)現(xiàn) 1.這個(gè)是在本頁(yè)面上的.cs文件里寫的 代碼如下:if (resultInt > 0) { //清除驗(yàn)證碼 ,顯示執(zhí)行結(jié)果,并轉(zhuǎn)向新的地址 Session[YanZhengMa] = ; String caoCode = if(confirm('提交成功,是否打印')) +