当前位置: 首页 > 图文教程 > 网络编程 > ASP > WEB打印设置解决方案三

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

ASP 中的 WEB打印设置解决方案三


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 120 ::
收藏到网摘: n/a

 

程序代码:
<script Language=VBScript> 
 Function print_onclick //打印函数 
  Dim label 
  label=document.printinfo.label.value //获得HTML页面的数据 
  set objfs=CreateObject("Scripting.FileSystemObject") //创建FileSystem组件对象的实例 
  set objprinter=objfs.CreateTextFile ("LPT1:",true) //建立与打印机的连接 
  objprinter.Writeline("__________________________________") //输出打印的内容 
  objprinter.Writeline("| |") 
  objprinter.Writeline("| 您打印的数据是:"&label& " |”) 
  objprinter.Writeline("| |") 
  objprinter.Writeline("|_________________________________|") 
  objprinter.close //断开与打印机的连接 
  Set objprinter = nothing 
  Set objfs = nothing // 关闭FileSystem组件对象 
 End Function 
</script> 

服务器端脚本: 
<% 
 Set conn=server.CreateObject ("adodb.connection") 
 conn.Open "DSN=name;UID=XXXX;PWD=XXXX;" 
 Set Rs = server.CreateObject("adodb.recordset") 
 Rs.Open("select ……"),conn,1,1 
%> //与数据库进行交互 

HTML页面编码: 
<HTML> 
……… 
<FORM ID=printinfo NAME="printinfo" > 
<INPUT type="button" value="打印>>" id=print name=print > //调用打印函数 
<INPUT type="hidden" id="text1" name="label" value=<%=………%>> //保存服务器端传来的数据 
……… 
</HTML>