古詩詞大全網 - 個性簽名 - ASP.NET(c#)如何實現web回單的打印功能?以前從未涉及過,請各位專家幫忙~謝謝!

ASP.NET(c#)如何實現web回單的打印功能?以前從未涉及過,請各位專家幫忙~謝謝!

有兩種方法:

1.純html+javascript

- print.js -

var hkey_root,hkey_path,hkey _ key

HKEY _ root = " HKEY _當前_用戶";

HKEY _ path = " \ \ Software \ \ Microsoft \ \ Internet Explorer \ \ page setup \ \ ";

//打印網頁時清除頁眉和頁腳。

函數pagesetup_null() {

嘗試{

var reg wsh = new ActiveX object(" WScript。外殼”)

hkey_key = "header "

RegWsh。RegWrite(HKEY _ root+HKEY _ path+HKEY _ key,"")

hkey_key = "頁腳"

RegWsh。RegWrite(HKEY _ root+HKEY _ path+HKEY _ key,"")

} catch (e) {

}

}

//打印網頁時,將頁眉和頁腳恢復為默認值。

函數pagesetup_default() {

嘗試{

var reg wsh = new ActiveX object(" WScript。外殼”)

hkey_key = "header "

RegWsh。RegWrite(HKEY _ root+HKEY _ path+HKEY _ key," & ampw & ampbPage & ampp of & ampp”)

hkey_key = "頁腳"

RegWsh。RegWrite(HKEY _ root+HKEY _ path+HKEY _ key," & ampu & ampb & ampd”)

} catch (e) {

}

}

函數doPrint(printDiv) {

嘗試{

page setup _ null();

newwin = window.open("," newwin "," height=900,width=700,toolbar=no,scrollbars=auto,menubar = no ");

new win . document . body . innerhtml = document . getelementbyid(print div)。innerHTML

new win . window . print();

new win . window . close();

page setup _ default();

} catch (e) { }

}

-

正面:

& ltscript language = JavaScript src = printer . js & gt;& lt/script & gt;

& ltdiv & gt

DIV1,不要打印我

& lt/div & gt;

& ltdiv id = " myDiv " & gt

第二行,需要打印

& lt/div & gt;

& ltdiv & gt

第3行,不要打印我& lt/div & gt;

& ltdiv & gt

& ltinput type = " button " id = " Bt " onclick = " JavaScript:doPrint(' my div ')" value = " Print "/& gt;

-

以上方法簡單易用,只需將打印內容放入mydiv中即可。

但是如果對方不加域名,訪問時無權修改別人的註冊表,就會出現頁眉頁腳。

2.用水晶報表做