0
我使用以下jQuery代碼來檢測條碼掃描並將條碼數據放入子頁面上的文本框中。眼下這個代碼是在子頁,它按預期工作:在母版頁的子頁面上設置文本框值
<script type="text/javascript" src="Scripts/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.scannerdetection.js"></script>
<script type="text/javascript">
$(document).scannerDetection({
minLength: 5, // override the default minLength of 6 since barrel numbers are 5 digits - otherwise onError is triggered
timeBeforeScanTest: 200, // wait for the next character for upto 200ms
endChar: [13], // be sure the scan is complete if key 13 (enter) is detected
avgTimeByChar: 40, // it's not a barcode if a character takes longer than 40ms
ignoreIfFocusOn: 'input', // turn off scanner detection if an input has focus
onComplete: function (barcode, qty) {
$('#<%= txtBarcode.ClientID%>').val(barcode);
$('#<%= btnRefresh.ClientID%>').click();
},// main callback function
scanButtonKeyCode: 116, // the hardware scan button acts as key 116 (F5)
scanButtonLongPressThreshold: 5, // assume a long press if 5 or more events come in sequence
onError: function (string) { alert('Error ' + string); }
});
</script>
我需要這個jQuery移動到我的母版頁,但我無法弄清楚如何引用都在txtBarcode和btnRefresh控制母版頁的子頁面。任何人都可以給我一些示例代碼的onComplete回調函數,這將允許我填寫從母版頁子頁面上的控件?
onComplete: function (barcode, qty) {
$('#<%= txtBarcode.ClientID%>').val(barcode);
$('#<%= btnRefresh.ClientID%>').click();
},// main callback function
謝謝!
非常感謝! cssClass完美地工作。 – gcresse