您的位置:程序门 -> .net技术 -> c#



打印问题,请帮忙!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


打印问题,请帮忙!
发表于:2007-04-11 10:07:22 楼主
我在页面上放了两个按钮,打印和页面预览。可是在执行时会出现没有权限
我把代码帖出来,谁帮我运行一下,谢谢了!
<%@   page   language= "c# "   codebehind= "webform4.aspx.cs "   autoeventwireup= "false "   inherits= "webapplication2.webform4 "   %>
<!doctype   html   public   "-//w3c//dtd   html   4.0   transitional//en "   >
<html>
<head>
<title> webform4 </title>
<meta   content= "microsoft   visual   studio   .net   7.1 "   name= "generator ">
<meta   content= "c# "   name= "code_language ">
<meta   content= "javascript "   name= "vs_defaultclientscript ">
<meta   content= "http://schemas.microsoft.com/intellisense/ie5 "   name= "vs_targetschema ">
<style   type= "text/css "   media= "print "> .p9   {   font-size:   9pt   }
table   {   font-size:   9pt   }
td   {   font-size:   9pt   }
body   {   font-size:   9pt;   visibility:   hidden;   color:   #000000   }
select   {   font-size:   9pt   }
a   {   visibility:   visible;   text-decoration:   none   }
a:link   {   color:   #000000;   text-decoration:   none   }
a:visited   {   color:   #408080;   text-decoration:   none   }
a:active   {   text-decoration:   none   }
a:hover   {   color:   #ff0000;   text-decoration:   underline   }
.yd_print   {   visibility:   visible;   position:   relative   }
.no_print   {   visibility:   hidden;   position:   relative   }
</style>
<script   language= "javascript ">
function   print1()  
{  
try  
{
var   net;
net   =   new   activexobject( "wscript.network ");  
net.setdefaultprinter( "单车核算 ");  
document.all.wb.EXECwb(6,2);//打印
}  
catch(e)  
{  
alert( '打印机没有准备好,请选择打印机! ');  
document.all.wb.EXECwb(7,1);//打印预览
}  
}  
function   print2()   //单独打印企业
{  
try  
{
var   net;
net   =   new   activexobject( "wscript.network ");  
net.setdefaultprinter( "单车核算 ");
document.all.wb.EXECwb(7,1);//打印预览
}  
catch(e)  
{  
alert( '打印机没有准备好,请选择打印机! ');  
document.all.wb.EXECwb(7,1);//打印预览
}  
}
</script>
<object   id= "wb "   height= "0 "   width= "0 "   classid= "clsid:8856f961-340a-11d0-a96b-00c04fd705a2 "
name= "wb "   viewastext>
<param   name= "extentx "   value= "7938 ">
<param   name= "extenty "   value= "3969 ">
<param   name= "viewmode "   value= "0 ">
<param   name= "offline "   value= "0 ">
<param   name= "silent "   value= "0 ">
<param   name= "registerasbrowser "   value= "0 ">
<param   name= "registerasdroptarget "   value= "1 ">
<param   name= "autoarrange "   value= "0 ">
<param   name= "noclientedge "   value= "0 ">
<param   name= "alignleft "   value= "0 ">
<param   name= "nowebview "   value= "0 ">
<param   name= "hidefilenames "   value= "0 ">
<param   name= "singleclick "   value= "0 ">
<param   name= "singleselection "   value= "0 ">
<param   name= "nofolders "   value= "0 ">
<param   name= "transparent "   value= "0 ">
<param   name= "viewid "   value= "{0057d0e0-3573-11cf-ae69-08002b2e1262} ">
<param   name= "location "   value= "res://c:\windows\system32\shdoclc.dll/dnserror.htm#http:/// ">
</object>
</head>
<body   ms_positioning= "gridlayout ">
<form   id= "form1 "   method= "post "   runat= "server ">
<table>
<tr   bgcolor= "#ffffff ">
<td   align= "center ">
<button   class= "no_print "   id= "imgdy "   onclick= "javascript:print1(); "   runat= "server "   type= "button ">
打印 </button> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   <button   class= "no_print "   id= "imgdyyl "   onclick= "javascript:print2(); "   runat= "server "   type= "button ">
页面预览 </button>
</td>
</tr>
</table>
</form>
</body>
</html>


快速检索

最新资讯
热门点击