.net实现生成及打印条形码功能

.net实现生成及打印条形码功能,下面简单总结了自己的实现方法。   
     1.引用dll文件
     将FLX.WebControls.dll文件拷贝到顶目的bin文件夹目录中;

    2.配置web.config文件
     在<system.web></system.web>之间添加如下代码
     <httpHandlers>
     <add verb="*" path="FlxBarCode.axd" type="FLX.WebControls.FlxBarCodeHandler,FLX.WebControls" />  
     </httpHandlers>

     3.新建aspx文件,代码如下
     前台文件:

 

[xhtml:firstline[1]]  view plain copy print ?
  1. <HTML>   
  2.     <HEAD>   
  3.         <title>打印条形码</title>   
  4.         <metacontent="Microsoft Visual Studio .NET 7.1"name="GENERATOR">   
  5.         <metacontent="C#"name="CODE_LANGUAGE">   
  6.         <metacontent="JavaScript"name="vs_defaultClientScript">   
  7.         <metacontent="http://schemas.microsoft.com/intellisense/ie5"name="vs_targetSchema">   
  8.         <LINKhref="Css/baseStyle.css"mce_href="Css/baseStyle.css"type="text/css"rel="stylesheet">   
  9.         <mce:stylemedia="print"><!-- 
  10. .noprint { DISPLAY: none } 
  11.          
  12. --></mce:style><mce:stylemedia="print"mce_bogus="1"><!-- 
  13. .noprint { DISPLAY: none } 
  14.          
  15. --></mce:style><mce:stylemedia="print"mce_bogus="1"mce_bogus="1"><!-- 
  16. .noprint { DISPLAY: none } 
  17.          
  18. --></mce:style><mce:stylemedia="print"mce_bogus="1"mce_bogus="1"mce_bogus="1"><!-- 
  19. .noprint { DISPLAY: none } 
  20.          
  21. --></mce:style><mce:stylemedia="print"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1"><!--
  22. .noprint { DISPLAY: none } 
  23.        
  24. --></mce:style><mce:stylemedia="print"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1"><!--
  25. .noprint { DISPLAY: none } 
  26.        
  27. --></mce:style><stylemedia="print"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1"mce_bogus="1">.noprint { DISPLAY: none }   
  28.         </style>   
  29.         <mce:scriptlanguage="javascript"src="scripts/print.js"mce_src="scripts/print.js"charset="gb2312"></mce:script>   
  30.         <STYLE> DIV.page { PAGE-BREAK-BEFORE: always }</STYLE>   
  31.     </HEAD>   
  32.     <body>   
  33.         <formid="Form2"method="post"runat="server">   
  34.             <spanid="message"class="noprint"></span>               
  35.             <br>   
  36.             <spanid="span"class="noprint"></span>   
  37.             <br>   
  38.             <br>   
  39.             <tableborder="1"cellspacing="0"cellpadding="0"width="70"bordercolor="#000000">   
  40.                 <tr>   
  41.                     <td>   
  42.                         <table>   
  43.                             <tr>   
  44.                                 <tdwidth="100%"valign="top"align="center"><asp:Labelid="LblName"runat="server"Font-Size="14px"Font-Bold="True"></asp:Label></td>   
  45.                             </tr>   
  46.                             <tr>   
  47.                                 <tdwidth="100%"valign="top">   
  48.                                     <palign="right"style="PADDING-RIGHT:5px"mce_style="PADDING-RIGHT:5px">   
  49.                                         <asp:Imageid="ImageCode"runat="server"></asp:Image>   
  50.                                     </p>   
  51.                                     <P><FONTface="宋体"></FONT></P>   
  52.                                 </td>   
  53.                             </tr>   
  54.                         </table>   
  55.                     </td>   
  56.                 </tr>   
  57.             </table>   
  58.         </form>   
  59.     </body>   
  60. </HTML>   

[xhtml:firstline[1]]  view plain copy print ?
  1. <HTML>    
  2.     <HEAD>    
  3.         <title>打印条形码</title>    
  4.         <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">    
  5.         <meta content="C#" name="CODE_LANGUAGE">    
  6.         <meta content="JavaScript" name="vs_defaultClientScript">    
  7.         <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">    
  8.         <LINK href="Css/baseStyle.css" mce_href="Css/baseStyle.css" type="text/css" rel="stylesheet">    
  9.         <mce:style media="print"><!--   
  10. .noprint { DISPLAY: none }   
  11.            
  12. --></mce:style><mce:style media="print" mce_bogus="1"><!--   
  13. .noprint { DISPLAY: none }   
  14.            
  15. --></mce:style><mce:style media="print" mce_bogus="1" mce_bogus="1"><!--   
  16. .noprint { DISPLAY: none }   
  17.            
  18. --></mce:style><mce:style media="print" mce_bogus="1" mce_bogus="1" mce_bogus="1"><!--   
  19. .noprint { DISPLAY: none }   
  20.            
  21. --></mce:style><mce:style media="print" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1"><!-- 
  22. .noprint { DISPLAY: none }   
  23.          
  24. --></mce:style><mce:style media="print" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1"><!-- 
  25. .noprint { DISPLAY: none }   
  26.          
  27. --></mce:style><style media="print" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1" mce_bogus="1">.noprint { DISPLAY: none }    
  28.         </style>    
  29.         <mce:script language="javascript" src="scripts/print.js" mce_src="scripts/print.js" charset="gb2312"></mce:script>    
  30.         <STYLE> DIV.page { PAGE-BREAK-BEFORE: always } </STYLE>    
  31.     </HEAD>    
  32.     <body>    
  33.         <form id="Form2" method="post" runat="server">    
  34.             <span id="message" class="noprint"></span>                
  35.             <br>    
  36.             <span id="span" class="noprint"></span>    
  37.             <br>    
  38.             <br>    
  39.             <table border="1" cellspacing="0" cellpadding="0" width="70" bordercolor="#000000">    
  40.                 <tr>    
  41.                     <td>    
  42.                         <table>    
  43.                             <tr>    
  44.                                 <td width="100%" valign="top" align="center"><asp:Label id="LblName" runat="server" Font-Size="14px" Font-Bold="True"></asp:Label></td>    
  45.                             </tr>    
  46.                             <tr>    
  47.                                 <td width="100%" valign="top">    
  48.                                     <p align="right" style="PADDING-RIGHT:5px" mce_style="PADDING-RIGHT:5px">    
  49.                                         <asp:Image id="ImageCode" runat="server"></asp:Image>    
  50.                                     </p>    
  51.                                     <P><FONT face="宋体"></FONT></P>    
  52.                                 </td>    
  53.                             </tr>    
  54.                         </table>    
  55.                     </td>    
  56.                 </tr>    
  57.             </table>    
  58.         </form>    
  59.     </body>    
  60. </HTML>    

后台文件:

 

[xhtml:firstline[1]]  view plain copy print ?
  1. protected System.Web.UI.WebControls.Image ImageCode;   
  2.      protected System.Web.UI.WebControls.Label LblName;   
  3.      private void Page_Load(object sender, System.EventArgs e)   
  4.      {   
  5.          // 在此处放置用户代码以初始化页面   
  6.          this.LblName.Text =Request.QueryString["Name"].ToString();   
  7.          this.ImageCode.ImageUrl =Request.QueryString["Url"].ToString();   
  8.      }         

[xhtml:firstline[1]]  view plain copy print ?
  1. protected System.Web.UI.WebControls.Image ImageCode;    
  2.      protected System.Web.UI.WebControls.Label LblName;    
  3.      private void Page_Load(object sender, System.EventArgs e)    
  4.      {    
  5.          // 在此处放置用户代码以初始化页面    
  6.          this.LblName.Text =Request.QueryString["Name"].ToString();    
  7.          this.ImageCode.ImageUrl =Request.QueryString["Url"].ToString();    
  8.      }          

引用JS代码:

 

  1. String.prototype.getQuery = function(name){   
  2.          var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");   
  3.          var r = this.substr(this.indexOf("/?")+1).match(reg);   
  4.          if (r != null)return unescape(r[2]);    
  5.          return null;   
  6.      }           
  7.         
  8.      //创建WebBrowser控件   
  9.      var createWebBrowser =function(){   
  10.          document.getElementById("span").innerHTML ='<object id="WebBrowser" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';   
  11.                 
  12.      }   
  13.      //创建按钮   
  14.      var createButton = function(vID,vValue,eventHandler){       
  15.          var btnButton = document.createElement("INPUT");   
  16.          btnButton.type ="Button";   
  17.          btnButton.id = vID;   
  18.          btnButton.value = vValue;   
  19.          btnButton.onclick = eventHandler;   
  20.          document.getElementById("span").appendChild(btnButton);   
  21.      }   
  22.      //创建标签   
  23.      var createSpan = function(vID,vValue,eventHandler){       
  24.          var htmSpan = document.createElement("span");   
  25.          htmSpan.id = vID;   
  26.          htmSpan.innerHTML = vValue;   
  27.          if(eventHandler !=null)   
  28.              htmSpan.onclick = eventHandler;   
  29.          document.getElementById("span").appendChild(htmSpan);   
  30.      }           
  31.      //创建标签   
  32.      var createTextBox = function(vID,vValue,eventHandler,width){       
  33.          var btnButton = document.createElement("INPUT");   
  34.          btnButton.type ="text";   
  35.          btnButton.id = vID;   
  36.          btnButton.value = vValue;   
  37.          btnButton.width = width;   
  38.          if(eventHandler != null)   
  39.              btnButton.onclick = eventHandler;   
  40.          document.getElementById("span").appendChild(btnButton);   
  41.      }           
  42.      //按钮事件   
  43.      var print = function(){   
  44.      pagesetup_null();   
  45.      document.all.WebBrowser.ExecWB(6,1);   
  46.      }   
  47.      var directPrint = function(){   
  48.          pagesetup_null();   
  49.          document.all.WebBrowser.ExecWB(6,6);   
  50.      }   
  51.      var PrintSetUp = function(){   
  52.          pagesetup_null();   
  53.          document.all.WebBrowser.ExecWB(8,1);   
  54.      }   
  55.      var PrintReview = function(){   
  56.          pagesetup_null();   
  57.          document.all.WebBrowser.ExecWB(7,1);   
  58.      }   
  59.      var PrintFirst = function(){   
  60.          window.location.href = window.location.href   
  61.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")  
  62.              +"&PageIndex=1";   
  63.      }   
  64.      var PrintLast = function(){   
  65.          var last = parseInt(window.location.toString().getQuery('LastPage'));   
  66.          window.location.href = window.location.href   
  67.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")  
  68.              +"&PageIndex="+last;   
  69.      }   
  70.      var PrintPre = function(){   
  71.          var index = parseInt(window.location.toString().getQuery('PageIndex'));   
  72.          if(index>1)   
  73.          window.location.href = window.location.href   
  74.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")  
  75.              +"&PageIndex="+(index-1);   
  76.          else alert("到头了");   
  77.      }   
  78.      var PrintNext = function(){   
  79.          var index = parseInt(window.location.toString().getQuery('PageIndex'));   
  80.          var last = parseInt(window.location.toString().getQuery('LastPage'));   
  81.          if((index+1)<=last)   
  82.          window.location.href = window.location.href   
  83.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")  
  84.              +"&PageIndex="+(index+1);   
  85.          else alert("到头了");   
  86.      }   
  87.      var ShowPageIndex= function(){   
  88.      }   
  89.      var GoPage= function(){   
  90.          var pageSize = document.getElementById('txtPageSize').value.replace(//s+/,"");  
  91.          if(/^/d+$/.test(pageSize))   
  92.          {   
  93.              var href = window.location.href.replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")  
  94.                  .replace(//?LastPage=(/d)*$/g,"").replace(//?LastPage=(/d)*&/g,"?").replace(/&LastPage=(/d)*&/g,"&").replace(/&LastPage=(/d)*$/g,"")  
  95.                  .replace(//?PageSize=(/d)*$/g,"").replace(//?PageSize=(/d)*&/g,"?").replace(/&PageSize=(/d)*&/g,"&").replace(/&PageSize=(/d)*$/g,"")  
  96.                  .replace(//?pagesize=(/d)*$/g,"").replace(//?pagesize=(/d)*&/g,"?").replace(/&pagesize=(/d)*&/g,"&").replace(/&pagesize=(/d)*$/g,"")  
  97.                  +"&PageSize="+pageSize;   
  98.              window.location.href = href;   
  99.          }   
  100.          else   
  101.          {   
  102.              alert("请输入数字");   
  103.              document.getElementById('txtPageSize').focus();   
  104.          }   
  105.      }           
  106.      //设置网页打印的页眉页脚为空   
  107.      function pagesetup_null(){                   
  108.          var     hkey_root,hkey_path,hkey_key;   
  109.          hkey_root="HKEY_CURRENT_USER"   
  110.          hkey_path="//Software//Microsoft//Internet Explorer//PageSetup//";   
  111.          try{   
  112.                          var RegWsh =new ActiveXObject("WScript.Shell");   
  113.                          hkey_key="header";   
  114.                      RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");   
  115.                      hkey_key="footer";   
  116.                      RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");   
  117.              }catch(e){}   
  118.      }   
  119.      window.onload = function(){   
  120.              document.getElementById('span').innerHTML ="";   
  121.              createWebBrowser();   
  122.              createButton("btn0","打印",print);   
  123.              createButton("btn1","直接打印",directPrint);   
  124.              createButton("btn2","页面设置",PrintSetUp);   
  125.              createButton("btn3","打印预览",PrintReview);   
  126.                 
  127.              if(window.location.toString().getQuery('PageSize') !=null || window.location.toString().getQuery('pagesize') !=null)   
  128.              {   
  129.                  createButton("btn4","第一页",PrintFirst);   
  130.                  createButton("btn5","上一页",PrintPre);   
  131.                  createButton("btn6","下一页",PrintNext);   
  132.                  createButton("btn7","末 页",PrintLast);   
  133.                  var index = parseInt(window.location.toString().getQuery('PageIndex'));   
  134.                  var last = parseInt(window.location.toString().getQuery('LastPage'));   
  135.                  createSpan("span0"," 当前第 "+index+"/"+last+" 页 ",null);   
  136.                  if(index==1){document.getElementById("btn5").disabled =true;document.getElementById("btn4").disabled =true;}   
  137.                  if(index==last){document.getElementById("btn6").disabled =true;document.getElementById("btn7").disabled =true;}   
  138.                     
  139.                  if(window.location.toString().getQuery('UserSetSize') !=null || window.location.toString().getQuery('usersetsize') !=null)   
  140.                  {   
  141.                      var usersetsize ="";   
  142.                      if(window.location.toString().getQuery('UserSetSize') !=null)   
  143.                          usersetsize = window.location.toString().getQuery('UserSetSize');   
  144.                      else if(window.location.toString().getQuery('usersetsize') !=null)   
  145.                          usersetsize = window.location.toString().getQuery('usersetsize');   
  146.                      if(usersetsize.toUpperCase()=='Y')   
  147.                      {   
  148.                          createSpan("span1","每页显示",null);   
  149.                          var pagesize = 0;   
  150.                          if(window.location.toString().getQuery('PageSize') !=null)   
  151.                              pagesize = parseInt(window.location.toString().getQuery('PageSize'));   
  152.                          else if(window.location.toString().getQuery('pagesize') !=null)   
  153.                              pagesize = parseInt(window.location.toString().getQuery('pagesize'));   
  154.                          createTextBox("txtPageSize",pagesize,null,40);   
  155.                          createButton("PageSizeSet","设 置",GoPage);   
  156.                      }   
  157.                  }   
  158.              }   
  159.              var mess = "<font color=red>如系统中的打印功能无法正常使用,请更改IE浏览器设置:<br>";   
  160.              mess +="更改步骤:1、选择IE功能菜单中工具(T)—>Internet选项(O);<br>";   
  161.              mess +="          2、在弹出的“Internet选项”窗口中,选择“安全”标签;<br>";   
  162.              mess +="          3、选择“自定义级别(C)”;<br>";   
  163.              mess +="          4、在弹出的“安全设置”窗口中,找到“ActiveX 控件和插件”项;<br>";   
  164.              mess +="          5、将其下面所有项选择为“启用”,然后“确定”。</font>";   
  165.        document.getElementById('message').innerHTML = mess;   
  166.      }   
  167.         

  1. String.prototype.getQuery = function(name){    
  2.          var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");    
  3.          var r = this.substr(this.indexOf("/?")+1).match(reg);    
  4.          if (r != nullreturn unescape(r[2]);     
  5.          return null;    
  6.      }            
  7.          
  8.      //创建WebBrowser控件    
  9.      var createWebBrowser = function(){    
  10.          document.getElementById("span").innerHTML = '<object id="WebBrowser" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';    
  11.                  
  12.      }    
  13.      //创建按钮    
  14.      var createButton = function(vID,vValue,eventHandler){        
  15.          var btnButton = document.createElement("INPUT");    
  16.          btnButton.type ="Button";    
  17.          btnButton.id = vID;    
  18.          btnButton.value = vValue;    
  19.          btnButton.onclick = eventHandler;    
  20.          document.getElementById("span").appendChild(btnButton);    
  21.      }    
  22.      //创建标签    
  23.      var createSpan = function(vID,vValue,eventHandler){        
  24.          var htmSpan = document.createElement("span");    
  25.          htmSpan.id = vID;    
  26.          htmSpan.innerHTML = vValue;    
  27.          if(eventHandler != null)    
  28.              htmSpan.onclick = eventHandler;    
  29.          document.getElementById("span").appendChild(htmSpan);    
  30.      }            
  31.      //创建标签    
  32.      var createTextBox = function(vID,vValue,eventHandler,width){        
  33.          var btnButton = document.createElement("INPUT");    
  34.          btnButton.type ="text";    
  35.          btnButton.id = vID;    
  36.          btnButton.value = vValue;    
  37.          btnButton.width = width;    
  38.          if(eventHandler != null)    
  39.              btnButton.onclick = eventHandler;    
  40.          document.getElementById("span").appendChild(btnButton);    
  41.      }            
  42.      //按钮事件    
  43.      var print = function(){    
  44.      pagesetup_null();    
  45.      document.all.WebBrowser.ExecWB(6,1);    
  46.      }    
  47.      var directPrint = function(){    
  48.          pagesetup_null();    
  49.          document.all.WebBrowser.ExecWB(6,6);    
  50.      }    
  51.      var PrintSetUp = function(){    
  52.          pagesetup_null();    
  53.          document.all.WebBrowser.ExecWB(8,1);    
  54.      }    
  55.      var PrintReview = function(){    
  56.          pagesetup_null();    
  57.          document.all.WebBrowser.ExecWB(7,1);    
  58.      }    
  59.      var PrintFirst = function(){    
  60.          window.location.href = window.location.href    
  61.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")    
  62.              +"&PageIndex=1";    
  63.      }    
  64.      var PrintLast = function(){    
  65.          var last = parseInt(window.location.toString().getQuery('LastPage'));    
  66.          window.location.href = window.location.href    
  67.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")    
  68.              +"&PageIndex="+last;    
  69.      }    
  70.      var PrintPre = function(){    
  71.          var index = parseInt(window.location.toString().getQuery('PageIndex'));    
  72.          if(index>1)    
  73.          window.location.href = window.location.href    
  74.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")    
  75.              +"&PageIndex="+(index-1);    
  76.          else alert("到头了");    
  77.      }    
  78.      var PrintNext = function(){    
  79.          var index = parseInt(window.location.toString().getQuery('PageIndex'));    
  80.          var last = parseInt(window.location.toString().getQuery('LastPage'));    
  81.          if((index+1)<=last)    
  82.          window.location.href = window.location.href    
  83.              .replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")    
  84.              +"&PageIndex="+(index+1);    
  85.          else alert("到头了");    
  86.      }    
  87.      var ShowPageIndex= function(){    
  88.      }    
  89.      var GoPage= function(){    
  90.          var pageSize = document.getElementById('txtPageSize').value.replace(//s+/,"");    
  91.          if(/^/d+$/.test(pageSize))    
  92.          {    
  93.              var href = window.location.href.replace(//?PageIndex=(/d)*$/g,"").replace(//?PageIndex=(/d)*&/g,"?").replace(/&PageIndex=(/d)*&/g,"&").replace(/&PageIndex=(/d)*$/g,"")    
  94.                  .replace(//?LastPage=(/d)*$/g,"").replace(//?LastPage=(/d)*&/g,"?").replace(/&LastPage=(/d)*&/g,"&").replace(/&LastPage=(/d)*$/g,"")    
  95.                  .replace(//?PageSize=(/d)*$/g,"").replace(//?PageSize=(/d)*&/g,"?").replace(/&PageSize=(/d)*&/g,"&").replace(/&PageSize=(/d)*$/g,"")    
  96.                  .replace(//?pagesize=(/d)*$/g,"").replace(//?pagesize=(/d)*&/g,"?").replace(/&pagesize=(/d)*&/g,"&").replace(/&pagesize=(/d)*$/g,"")    
  97.                  +"&PageSize="+pageSize;    
  98.              window.location.href = href;    
  99.          }    
  100.          else    
  101.          {    
  102.              alert("请输入数字");    
  103.              document.getElementById('txtPageSize').focus();    
  104.          }    
  105.      }            
  106.      //设置网页打印的页眉页脚为空    
  107.      function pagesetup_null(){                    
  108.          var     hkey_root,hkey_path,hkey_key;    
  109.          hkey_root="HKEY_CURRENT_USER"    
  110.          hkey_path="//Software//Microsoft//Internet Explorer//PageSetup//";    
  111.          try{    
  112.                          var RegWsh = new ActiveXObject("WScript.Shell");    
  113.                          hkey_key="header";    
  114.                      RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");    
  115.                      hkey_key="footer";    
  116.                      RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");    
  117.              }catch(e){}    
  118.      }    
  119.      window.onload = function(){    
  120.              document.getElementById('span').innerHTML = "";    
  121.              createWebBrowser();    
  122.              createButton("btn0","打印",print);    
  123.              createButton("btn1","直接打印",directPrint);    
  124.              createButton("btn2","页面设置",PrintSetUp);    
  125.              createButton("btn3","打印预览",PrintReview);    
  126.                  
  127.              if(window.location.toString().getQuery('PageSize') != null || window.location.toString().getQuery('pagesize') != null)    
  128.              {    
  129.                  createButton("btn4","第一页",PrintFirst);    
  130.                  createButton("btn5","上一页",PrintPre);    
  131.                  createButton("btn6","下一页",PrintNext);    
  132.                  createButton("btn7","末 页",PrintLast);    
  133.                  var index = parseInt(window.location.toString().getQuery('PageIndex'));    
  134.                  var last = parseInt(window.location.toString().getQuery('LastPage'));    
  135.                  createSpan("span0"," 当前第 "+index+"/"+last+" 页 ",null);    
  136.                  if(index==1){document.getElementById("btn5").disabled = true;document.getElementById("btn4").disabled = true;}    
  137.                  if(index==last){document.getElementById("btn6").disabled = true;document.getElementById("btn7").disabled = true;}    
  138.                      
  139.                  if(window.location.toString().getQuery('UserSetSize') != null || window.location.toString().getQuery('usersetsize') != null)    
  140.                  {    
  141.                      var usersetsize = "";    
  142.                      if(window.location.toString().getQuery('UserSetSize') != null)    
  143.                          usersetsize = window.location.toString().getQuery('UserSetSize');    
  144.                      else if(window.location.toString().getQuery('usersetsize') != null)    
  145.                          usersetsize = window.location.toString().getQuery('usersetsize');    
  146.                      if(usersetsize.toUpperCase()=='Y')    
  147.                      {    
  148.                          createSpan("span1","每页显示",null);    
  149.                          var pagesize = 0;    
  150.                          if(window.location.toString().getQuery('PageSize') != null)    
  151.                              pagesize = parseInt(window.location.toString().getQuery('PageSize'));    
  152.                          else if(window.location.toString().getQuery('pagesize') != null)    
  153.                              pagesize = parseInt(window.location.toString().getQuery('pagesize'));    
  154.                          createTextBox("txtPageSize",pagesize,null,40);    
  155.                          createButton("PageSizeSet","设 置",GoPage);    
  156.                      }    
  157.                  }    
  158.              }    
  159.              var mess = "<font color=red>如系统中的打印功能无法正常使用,请更改IE浏览器设置:<br>";    
  160.              mess +="更改步骤:1、选择IE功能菜单中工具(T)—>Internet选项(O);<br>";    
  161.              mess +="          2、在弹出的“Internet选项”窗口中,选择“安全”标签;<br>";    
  162.              mess +="          3、选择“自定义级别(C)”;<br>";    
  163.              mess +="          4、在弹出的“安全设置”窗口中,找到“ActiveX 控件和插件”项;<br>";    
  164.              mess +="          5、将其下面所有项选择为“启用”,然后“确定”。</font>";    
  165.        document.getElementById('message').innerHTML = mess;    
  166.      }    
  167.          

CSS代码:

 

  1. body   
  2. {   
  3.   background-color:White;    
  4.   font-family:宋体;    
  5.   font-size:9pt;   
  6.   color:#3F3F3F;    
  7. }   
  8. td, div   
  9. {   
  10.   font-family:宋体;    
  11.   font-size:9pt;   
  12. }   
  13. a   
  14. {   
  15.   color:#DD3409;   
  16.   text-decoration:none;    
  17. }   
  18. a:hover   
  19. {   
  20.   color:#DD3409;   
  21.   text-decoration:underline;    
  22. }   
  23. ul   
  24. {   
  25.   list-style-imageurl(images/bullet.gif);   
  26.   list-style-type:square;    
  27.   list-style-position:outside;    
  28.   margin-left:18px;    
  29.   margin-top:5px;    
  30.   color:#666666;   
  31.   padding-left:2px;   
  32. }   
  33. ol   
  34. {   
  35.   list-style-position:outside;    
  36.   margin-left:25px;    
  37.   margin-top:5px;    
  38. }   
  39. h1   
  40. {   
  41.   font-family:宋体;    
  42.   font-weight:bold;   
  43.   font-size:18px;    
  44.   color:#3F3F3F;   
  45.   margin-top:12px;    
  46.   margin-bottom:40px;    
  47. }   
  48. h2   
  49. {   
  50.   font-family:宋体;    
  51.   font-weight:bold;   
  52.   font-size:18px;    
  53.   color:#3F3F3F;   
  54.   margin-top:15px;    
  55.   margin-bottom:15px;    
  56. }   
  57. h3   
  58. {   
  59.   font-family:宋体;    
  60.   font-weight:bold;   
  61.   font-size:12px;    
  62.   margin-top:2px;    
  63.   margin-bottom:2px;    
  64. }   
  65. .TopNavLink   
  66. {   
  67.   font-size:9pt;   
  68.   color:#3F3F3F;    
  69. }   
  70. .WelcomeTitle   
  71. {   
  72.   font-family:宋体;   
  73.   font-size:23px;      
  74.   font-weight:900;    
  75.   letter-spacing:-0.2mm;   
  76.   margin-top:9pt;    
  77.   margin-bottom:20px;    
  78. }   
  79. .MainText   
  80. {   
  81.   font-size:9pt;    
  82. }   
  83. .SmallText   
  84. {   
  85.   font-size:9pt;    
  86. }   
  87. .Hint   
  88. {   
  89.   color:Red;   
  90. }   
  91. .DemoArea   
  92. {   
  93.   border:1pxsilversolid;    
  94.   padding:8px;   
  95.   background-color:#F6F6F6;   
  96. }   
  97. .AboutBox   
  98. {   
  99.   border:1px#E6E6E6solid;    
  100.   background-color:#DDDDDD;    
  101.   background-imageurl(images/about_background.gif);    
  102. }   
  103. .SidePanel   
  104. {    
  105.   padding9pt;    
  106.   border:1px;    
  107.   border-color:#AAAAAA;    
  108.   border-stylesolid;    
  109.   background-color:#F3F3F3;   
  110.   font-size:9pt;   
  111.   color:#666666;   
  112. }    
  113. .DemosNav    
  114. {    
  115.   padding0px;    
  116.   border:1px;    
  117.   border-color:#AAAAAA;    
  118.   border-stylesolid;    
  119.   background-color:#F3F3F3;   
  120. }    
  121. .DemoCategory    
  122. {    
  123.   color:black;    
  124.   font-family: 宋体;    
  125.   font-size9pt;    
  126.   font-weight:bold;    
  127.   cursordefault;    
  128. }    
  129. .DemoCategoryOver   
  130. {    
  131.   color:black;    
  132.   font-family: 宋体;    
  133.   font-size9pt;    
  134.   font-weight:bold;    
  135.   text-decoration:underline;    
  136.   cursordefault;    
  137. }    
  138. .Demo    
  139. {    
  140.   font-family: 宋体;    
  141.   font-size9pt;    
  142.   padding1px;    
  143.   padding-left:2px;   
  144.   padding-right:2px;   
  145.   border:1px;    
  146.   border-color:#F3F3F3;    
  147.   border-stylesolid;    
  148.   cursordefault;    
  149. }    
  150. .DemoHover    
  151. {   
  152.   font-family: 宋体;    
  153.   font-size9pt;    
  154.   padding1px;    
  155.   padding-left2px;    
  156.   padding-right2px;    
  157.   background-color:#cccccc;    
  158.   border:1px;    
  159.   border-color:gray;    
  160.   border-stylesolid;    
  161.   cursordefault;    
  162. }   
  163. .DemoSelected    
  164. {   
  165.   font-family: 宋体;    
  166.   font-size9pt;    
  167.   padding1px;    
  168.   padding-left2px;    
  169.   padding-right2px;    
  170.   background-color:#FFFFFF;    
  171.   border:1px;    
  172.   border-color:gray;    
  173.   border-stylesolid;    
  174.   cursordefault;    
  175. }   
  176. input   
  177. {   
  178.   font-family: 宋体;    
  179.   font-size9pt;    
  180. }     
  181. select   
  182. {   
  183.   font-family:宋体;    
  184.   font-size:9pt;   
  185. }   

  1. body    
  2. {    
  3.   background-color:White;     
  4.   font-family:宋体;     
  5.   font-size:9pt;    
  6.   color:#3F3F3F;     
  7. }    
  8. td, div    
  9. {    
  10.   font-family:宋体;     
  11.   font-size:9pt;    
  12. }    
  13. a    
  14. {    
  15.   color:#DD3409;    
  16.   text-decoration:none;     
  17. }    
  18. a:hover    
  19. {    
  20.   color:#DD3409;    
  21.   text-decoration:underline;     
  22. }    
  23. ul    
  24. {    
  25.   list-style-imageurl(images/bullet.gif);    
  26.   list-style-type:square;     
  27.   list-style-position:outside;     
  28.   margin-left:18px;     
  29.   margin-top:5px;     
  30.   color:#666666;    
  31.   padding-left:2px;    
  32. }    
  33. ol    
  34. {    
  35.   list-style-position:outside;     
  36.   margin-left:25px;     
  37.   margin-top:5px;     
  38. }    
  39. h1    
  40. {    
  41.   font-family:宋体;     
  42.   font-weight:bold;    
  43.   font-size:18px;     
  44.   color:#3F3F3F;    
  45.   margin-top:12px;     
  46.   margin-bottom:40px;     
  47. }    
  48. h2    
  49. {    
  50.   font-family:宋体;     
  51.   font-weight:bold;    
  52.   font-size:18px;     
  53.   color:#3F3F3F;    
  54.   margin-top:15px;     
  55.   margin-bottom:15px;     
  56. }    
  57. h3    
  58. {    
  59.   font-family:宋体;     
  60.   font-weight:bold;    
  61.   font-size:12px;     
  62.   margin-top:2px;     
  63.   margin-bottom:2px;     
  64. }    
  65. .TopNavLink    
  66. {    
  67.   font-size:9pt;    
  68.   color:#3F3F3F;     
  69. }    
  70. .WelcomeTitle    
  71. {    
  72.   font-family:宋体;    
  73.   font-size:23px;       
  74.   font-weight:900;     
  75.   letter-spacing:-0.2mm;    
  76.   margin-top:9pt;     
  77.   margin-bottom:20px;     
  78. }    
  79. .MainText    
  80. {    
  81.   font-size:9pt;     
  82. }    
  83. .SmallText    
  84. {    
  85.   font-size:9pt;     
  86. }    
  87. .Hint    
  88. {    
  89.   color:Red;    
  90. }    
  91. .DemoArea    
  92. {    
  93.   border:1px silver solid;     
  94.   padding:8px;    
  95.   background-color:#F6F6F6;    
  96. }    
  97. .AboutBox    
  98. {    
  99.   border:1px #E6E6E6 solid;     
  100.   background-color:#DDDDDD;     
  101.   background-imageurl(images/about_background.gif);     
  102. }    
  103. .SidePanel    
  104. {     
  105.   padding9pt;     
  106.   border:1px;     
  107.   border-color:#AAAAAA;     
  108.   border-stylesolid;     
  109.   background-color:#F3F3F3;    
  110.   font-size:9pt;    
  111.   color:#666666;    
  112. }     
  113. .DemosNav     
  114. {     
  115.   padding0px;     
  116.   border:1px;     
  117.   border-color:#AAAAAA;     
  118.   border-stylesolid;     
  119.   background-color:#F3F3F3;    
  120. }     
  121. .DemoCategory     
  122. {     
  123.   color:black;     
  124.   font-family: 宋体;     
  125.   font-size9pt;     
  126.   font-weight:bold;     
  127.   cursordefault;     
  128. }     
  129. .DemoCategoryOver    
  130. {     
  131.   color:black;     
  132.   font-family: 宋体;     
  133.   font-size9pt;     
  134.   font-weight:bold;     
  135.   text-decoration:underline;     
  136.   cursordefault;     
  137. }     
  138. .Demo     
  139. {     
  140.   font-family: 宋体;     
  141.   font-size9pt;     
  142.   padding1px;     
  143.   padding-left:2px;    
  144.   padding-right:2px;    
  145.   border:1px;     
  146.   border-color:#F3F3F3;     
  147.   border-stylesolid;     
  148.   cursordefault;     
  149. }     
  150. .DemoHover     
  151. {    
  152.   font-family: 宋体;     
  153.   font-size9pt;     
  154.   padding1px;     
  155.   padding-left2px;     
  156.   padding-right2px;     
  157.   background-color:#cccccc;     
  158.   border:1px;     
  159.   border-color:gray;     
  160.   border-stylesolid;     
  161.   cursordefault;     
  162. }    
  163. .DemoSelected     
  164. {    
  165.   font-family: 宋体;     
  166.   font-size9pt;     
  167.   padding1px;     
  168.   padding-left2px;     
  169.   padding-right2px;     
  170.   background-color:#FFFFFF;     
  171.   border:1px;     
  172.   border-color:gray;     
  173.   border-stylesolid;     
  174.   cursordefault;     
  175. }    
  176. input    
  177. {    
  178.   font-family: 宋体;     
  179.   font-size9pt;     
  180. }      
  181. select    
  182. {    
  183.   font-family:宋体;     
  184.   font-size:9pt;    
  185. }    

调用此方法:

 

  1. <mce:scriptlanguage="javascript"type="text/javascript"><!--   
  2.        
  3.         function PrintTXM()   
  4.         {   
  5.             var name =document.getElementById("TextBox_xm").value;     
  6.             var txturl = document.getElementById("TextBox_txm").value;   
  7.             //flxBarcode.axd?Text=11AA0A3B1487A19AB1Width=60Height=60   
  8.             var imageurl = 'flxBarcode.axd?Text='+txturl+'Width=60Height=60';   
  9.             var url = 'gwy_webprint.aspx?Name='+name+'Url='+imageurl;   
  10.             window.open(url, "_blank");   
  11.         }   
  12.            
  13. // --></mce:script>   
  14. <INPUT id="BtnPrint"type="button"value="打印"onclick="PrintTXM()">  

  1.  <mce:script language="javascript" type="text/javascript"><!--    
  2.         
  3.         function PrintTXM()    
  4.         {    
  5.             var name = document.getElementById("TextBox_xm").value;      
  6.             var txturl = document.getElementById("TextBox_txm").value;    
  7.             //flxBarcode.axd?Text=11AA0A3B1487A19AB1Width=60Height=60    
  8.             var imageurl = 'flxBarcode.axd?Text='+txturl+'Width=60Height=60';    
  9.             var url = 'gwy_webprint.aspx?Name='+name+'Url='+imageurl;    
  10.             window.open(url, "_blank");    
  11.         }    
  12.             
  13. // --></mce:script>    
  14. <INPUT id="BtnPrint" type="button" value="打印" onclick="PrintTXM()">   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值