简体   繁体   English

如何使用ASP.Net MVC 5将条形码阅读器连接到Web应用程序

[英]How to connect a barcode reader using ASP.Net MVC 5 for a web application

I developing a web application. 我开发了一个Web应用程序。 Can i enable it to read barcodes using barcode reader with ASP.Net MVC 5. What sort of API or Library i should use? 我是否可以使用条形码阅读器和ASP.Net MVC 5来读取条形码。我应该使用哪种API或库?

I want to read barcodes in my web application using a barcode reader 我想使用条形码阅读器在我的Web应用程序中阅读条形码

you have to read the event through Javascript. 你必须通过Javascript阅读该事件。 (In browser, on key press) Best option for you is HID scanner. (在浏览器中,按键时)最适合您的是HID扫描仪。 it works like a keyboard 它像键盘一样工作

scanner would enter characters faster. 扫描仪会更快地输入字符。 you can use this link for example. 例如,您可以使用此链接。 Detect when input box filled by keyboard and when by barcode scanner. 当键盘输入框和条形码扫描仪填充时检测。

or you can add a prefix to your barcode and onkeypress you can see which combination is entered. 或者您可以为条形码和onkeypress添加前缀,您可以看到输入了哪种组合。

The first thing you need to is to prevent postback when item barcode is scanned. 您需要做的第一件事是在扫描项目条形码时防止回发。 It is because the barcode scanner will send an enter key after item is scanned. 这是因为条形码扫描器将在扫描项目后发送回车键。 You need to create a script to convert enter key to tab 您需要创建一个脚本以将Enter键转换为Tab键

$(document).ready(function () {
        var self = $(this)
       , form = self.parents('form:eq(0)')
       , focusable
       , next
        ;
        if (e.keyCode == 13) {
            focusable = form.find('input,a,select,button,textarea').filter(':visible');
            next = focusable.eq(focusable.index(this) + 1);
            if (next.length) {
                next.focus();
            } else {
                form.submit();
            }
            return false;
        }
});

After that, you may scan the barcode wherever you like. 之后,您可以随时随地扫描条形码。 API is not needed for barcode. 条形码不需要API。 it works like a keyboard except that it converts barcode to readable text. 它像键盘一样工作,除了它将条形码转换为可读文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM