C#读卡器实现
来源:互联网 发布:linux vsftp安装包 编辑:程序博客网 时间:2024/05/16 01:07
申明:该代码适用于网页形式的读卡器功能实现。
直接上代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="c_reg.aspx.cs" Inherits="zhaopin.c_reg" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <object id="OCX" name="OCX" width="0" height="0" classid="CLSID:220C3AD1-5E9D-4B06-870F-E34662E2DFEA" codebase="IdrOcx.cab#version=1,0,1,2"></object><%--添加上面一个对象,代表引用读卡器很重要,必须申明 --% ><%--添加下面的代码用于读取数据,身份证,姓名, --%><table width="100%" border="0" cellspacing="0" cellpadding="0" class="table01"> <td height="32" align="right" class="text12" style="width: 20%">身份证:</td> <td width="67%" align="left"> <asp:TextBox ID="txt_sfz" runat="server" Width="243px" ></asp:TextBox> </td> </tr> <tr> <td height="32" align="right" class="text12" style="width: 20%" >法人代表:</td> <td width="67%" align="left"> <asp:TextBox ID="txt_name" runat="server" Width="243px" ></asp:TextBox> </td> <td> <asp:Button ID="Button1" runat="server" Text="读卡" OnClientClick="ReadMachine()"/> </td> </tr> </table> <div class="aspNetHidden"> <script type="text/javascript"> var BuyerNameID = '<%=txt_name.ClientID%>'; var BuyerIDID = '<%=txt_sfz.ClientID%>'; var GT2ICROCX = document.getElementById('OCX'); function MyGetData()//GT2ICROCX读卡成功后的回调函数 { //alert("123"); var name = document.getElementById(BuyerNameID); name.value = GT2ICROCX.NameL; var id = document.getElementById(BuyerIDID); id.value = GT2ICROCX.CardNo; if (GT2ICROCX.Sex == "1") { var sex = document.getElementById(ddlBuyerSexID); sex.value = "男"; } else { var sex = document.getElementById(ddlBuyerSexID); sex.value = "女"; } // var birth = GT2ICROCX.BornL; // birth = birth.replace("年", "-"); // birth = birth.replace("月", "-"); // birth = birth.replace("日", "-"); // F(BuyerBirthdayID).setValue(birth); //GT2ICROCX.Address)得到地址 } function MyClearData()//GT2ICROCX读卡失败后的回调函数 { alert(GT2ICROCX.ErrMsg); } function MyGetErrMsg()//GT2ICROCX读卡消息回调函数 { //alert(GT2ICROCX.ErrMsg); } function ReadMachine() { try { var a = GT2ICROCX.GetState(); if (a == -4) { alert("未检测到器具!"); return; } GT2ICROCX.PhotoPath = "" a = GT2ICROCX.ReadCard(); if (a == -6) { alert("读身份证失败!未检测到卡!"); return; } if (a == -200) { alert("验证卡失败,没有找到卡或者需要将卡拿离验证区重新读卡!"); return; } } catch (err) { alert("驱动未安装,或驱动不正确!"); } }</script><%--研腾读卡--%><script language="javascript" for="OCX" event="GetData"> //OCX读卡成功后的回调函数 MyGetData();</script><script language="javascript" for="OCX" event="GetErrMsg"> //OCX读卡消息回调函数 MyGetErrMsg();</script><script language="javascript" for="OCX" event="ClearData"> //OCX读卡失败后的回调函数 MyClearData();</script></div></asp:Content>
以上便可实现读卡功能。
1 0
- C#读卡器实现
- 串口ic读卡器c#代码
- 读卡器
- 使用读卡器实现pos消费
- 读卡器的状态机, python实现
- c# 键盘接口的磁条读卡器
- 神思二代身份证读卡器Demo——C#
- C#读IC卡程序(明华读卡器)
- C#调用C++DLL 使用 德卡 读卡器 获取身份证信息
- 新中新二代身份证读卡器C#开发问题及解决方法
- 新中新二代身份证读卡器C#开发问题及解决方法
- 基于W7100的以太网读卡器的设计与实现
- web.xml 配置listener实现RXTX串口通信(读卡器)
- 智能读卡器
- 身份证读卡器
- usb读卡器
- KS8U读卡器
- 使用C#调用金诚信71x系列读卡器的DLL
- 转 localStorage
- 搜集的一些项目源码,改改就能用
- android UiAutomator了解源码解决控件bonds[0,0]无法点击
- Trie树
- 用Java声明一个方法(函数)找出输入数值的范围去全部素数(质数)
- C#读卡器实现
- Docker入门教程(一)——基本介绍
- ARM的指令集
- Linux学习——Vim
- 变量的命名、定义和初始化
- bean 之间的关系:继承;依赖
- 函数变量作用域
- 我为什么要写博客
- 《View的事件体系》(二)View的滑动实现