首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

|M| A页面打印B页面有关问题

2012-01-03 
|M| A页面打印B页面问题index.htm有一个button控件点击这个按钮要可以打印http://community.csdn.net/Expe

|M| A页面打印B页面问题
index.htm
有一个button控件
点击这个按钮要可以打印
http://community.csdn.net/Expert/PostNew.asp?room=5202
这个页面

要求是:点击button不要用open在新窗口打印;而是点击button什么也没有反应就在打印机直接打印出来

谢谢



[解决办法]
打印机出来?学习~~~~
[解决办法]
帮顶。遇到同样的问题。
[解决办法]
除非用ActiveX,此外没有别的办法,因为Web不会保持不显示的数据。
[解决办法]
实际还是使用了winopen 但是可以将页面移出 屏幕 这样即可达到楼主不想看到窗口的效果
===index.aspx中===========
<script>
function winopen(__URL)
{
window.open(__URL, "打印帮助 ", "toolbar=no,menubar=no,resizable=yes, scrollbars=yes,top=3000px,left=3000 ");
}
</script>
<input type= "button " id= "prtBt " value= "打印帮助 " onclick= "winopen( 'help.aspx?prt=yes '); " />

======help.aspx==========================

<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "help.aspx.cs " Inherits= "help " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<Script language= "JavaScript ">

var hkey_root,hkey_path,hkey_key
hkey_root= "HKEY_CURRENT_USER "
hkey_path= "\\\\Software\\\\Microsoft\\\\Internet Explorer\\\\PageSetup\\\\ "

// 设置页眉页脚为空
function PageSetup_Null()
{
try{
var RegWsh = new ActiveXObject( "WScript.Shell ") ;
hkey_key= "header " ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key, " ") ;
hkey_key= "footer " ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key, " ") ;
}
catch(e){}
}

// 设置页眉页脚为默认值
function PageSetup_Default()
{
try{
var RegWsh = new ActiveXObject( "WScript.Shell ") ;
hkey_key= "header " ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key, "&w&b页码,&p/&P ") ;
hkey_key= "footer " ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key, "&u&b&d ") ;
}
catch(e){}
}

// 打印
function PrintPage()
{
PageSetup_Null();
wb.execwb(6,1);
PageSetup_Default();
window.opener = null;
parent.close();
}

</Script>
</head>
<body>
<object classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 " height=0 id=WB name=wb width=0 VIEWASTEXT> </object>
<form id= "form1 " runat= "server ">
<div>
</div>
</form>
</body>
</html>

=======help.aspx.cs============

protected void Page_Load(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(Request[ "prt "]))
{
Page.RegisterStartupScript( "printhtml ", " <script> PrintPage(); </script> ");


}
}

[解决办法]
自己写一个activex
[解决办法]
的那个打印会弹出选择打印机的窗口要怎么才能直接打印呢===========不行的. wb.execwb(6,6); 是立即打印,但也会弹出确定对话框
[解决办法]
通过修改注册表的方法基本行不通的,没有客户端权限
[解决办法]
up
[解决办法]
up

热点排行