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

一.在服務器端實現
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這個頁面上寫上
<body onload="vbscript:window.print()">
就可以了
二.在客戶端實現
代碼如下:
<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-->打印地方的結尾
<a href="javascript:;" onclick="doPrint()">打 印 </a>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
代碼實現打印功能(asp.net+javascript)
代碼實現打印功能(asp.net+javascript):一.在服務器端實現 1.這個是在本頁面上的.cs文件里寫的 代碼如下:if (resultInt > 0) { //清除驗證碼 ,顯示執行結果,并轉向新的地址 Session[YanZhengMa] = ; String caoCode = if(confirm('提交成功,是否打印')) +