Everyone knows,Asp.netIt is executed on the server.ProgramBut the customer proposed whether to directly call the second generation ID card reader on the webpage.
I. Solution
After our analysis, it is theoretically feasible. The following describes how to solve this problem.
1. compile a acitivex controls that connect to the ID card reader And read the contents on the card.
2. JavaScript call ActiveX to read the information on the ID card and fill it in the text input box on the page.
3.ExploitationJavascriptUpload the photo file of your ID card to the server. .
2. Development Environment
1.We use the guoteng Second Generation ID card reader. Other card readers are also similar and provideSDKVolunteer call
2.UseVs2005As a development tool
3. Detailed steps
1 , Developed to read the ID card reader ActiveX Control: because of C ++ Not very familiar, so developed ActiveX Controls use familiar C # Language, used C # The disadvantage of the language is that the client must be installed . Net framework2.0 .
The implementation of this control is to call the card reader's SDK , Read text information (such as ID card number) on the ID card / Gender / Date of birth / Issuing Authority / ID card address), and can also read the photo information. Because the device we use directly generates this information C The root directory, so I use a program to directly read these files.
About how to useC #DevelopmentActiveXFor more information, seeArticle:
Http://www.cnblogs.com/homer/archive/2005/01/04/86473.html
2, How to writeJavascriptCode
In JavaScript, how to initialize ActiveX controls and call ActiveX control methods.
A. Call the initialization control.
VaR Hello;
Try {
Hello = New Activexobject ( " Train. Reg. Demo " );
} Catch (ERR ){
Alert ( ' You may not have installed the ID card reader correctly or the browser settings are incorrect! \ N error message: ' + Err. Description + ' \ N for more information, see help! ' );
}
B. Call the Control Method
Code
VaR H = Hello. testcall ();
If (H = Null ) Return False ;
VaR Vidcardno = Document. getelementbyid ( ' <% = Txtidcardno. clientid %> ' );
Vidcardno. Value = H. idcardno;
VaR Vname = Document. getelementbyid ( ' <% = Txtfullname. clientid %> ' );
Vname. Value = H. Name;
var aaddress = document. getelementbyid ( ' <% = txtaddress. clientid %> ' );
aaddress. value = H. address;
VaRVsex=Document. getelementbyid ('<% = Ddlsex. clientid %>');
Vsex. Value=H. sex;
C. Use the fileupload component in vs2005 to upload images
Code
VaR Vuploadpath = Document. getelementbyid ( ' <% = Fileupload1.clientid %> ' );
Vuploadpath. Focus ();
VaR Wshshell;
Try {
Wshshell = New Activexobject ( " Wscript. Shell " );
} Catch (ERR ){
Alert ( ' Unable to read photo information: Incorrect browser settings! \ N error message: ' + Err. Description + ' \ N you need to set the browser to initialize the ActiveX control that is not marked as a secure script and execute the script to enable \ n or refer to help! ' );
}
Wshshell. sendkeys (H. photopath );
Wshshell. sendkeys ( " {Tab} " );
// Vuploadpath. src = H. photopath;
SetTimeout ( Function () {__ Dopostback ( ' Ctl00 $ contentplaceholder1 $ lbupload ' , '' );}, 0 );