5 Replies Latest reply on Nov 30, 2012 5:42 AM by Benedict Kennedy

    RhoElements ASP.Net app - first scan works, subsequent scans don't?

      I have a vb.net page that is running on a MC9190G using RhoElements

       

       

      I scan a serial number barcode, do a database update and clear the field in the "code behind"

      When I try to scan a second serial number barcode, the barcode data does not register in the field.

      An I missing something in my decode?

       

      .aspx code:

      -------------------------------------------------------------------------------------------------------------

      <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mo_pi_scan_mat_serial.aspx.vb" Inherits="kawashima_02.mo_scan_mat_serial" SmartNavigation="false" %>

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <html>
          <head>
              <title>PI Scan Material</title>
      <link rel="STYLESHEET" href="erpnow.css" type="text/css" />

          </head>
         <meta http-equiv="scanner"
                           content="DecodeEvent:url('Javascript:doScanDecode('%1', '%2', '%6');'); enabled" />
          <!--<meta http-equiv="quitbutton" content="visibility:visible;" />-->
         <body <%=str_focus%> >

      <center>
      <h1>Physical Inventory<br /> Scan Material with Serial #</h1>
      </center>
      <form id="mo_scan_mat_serial" runat="server">
      <font size="5">Select Warehouse:</font> <br />
      <asp:DropDownList id="ddl_whse" style='font-size:28;' Width="220" runat="server"></asp:DropDownList><br />
      <font size="5">Scan Location:</font> <br />
      <asp:textbox id="tb_location"  maxlength=20 style='font-size:28;' input class='UpperText' Width="220" runat="server"></asp:textbox><br />
      <font size="5">Scan Serial:</font><br />
      <asp:textbox id="tb_serial"   style='font-size:28;' input class='UpperText' Width="220" runat="server"></asp:textbox><br />
      <br />
      <font size="5">Partial Amount:</font>  <asp:textbox id="tb_partial"  maxlength=10 style='font-size:28;' Width="120" runat="server"></asp:textbox>
      <br />
      <input type="submit" value="Submit" name="submit" style='font-size:48;' />
      <input type="submit" value="Exit" name="submit" style='font-size:48;' />
      </form>
      <script language="JavaScript" type="text/javascript">

      function setFocus_serial()
      {
          document.mo_scan_mat_serial.tb_serial.focus();
      }
      function setFocus_location()
      {
          document.mo_scan_mat_serial.tb_location.focus();
      }
      function setFocus_partial()
      {
          document.mo_scan_mat_serial.tb_partial.focus();
      }

      function doScanDecode(data, source, eventtype)
      {
               if(eventtype != 'Decode')
                  return;
                 
               var focused=document.activeElement;
               focused.value = data;      
      }
         </script>
      </body>
      </html>

      ----------------------------------------------------------------

       

       

       

      Screen image attached

      Thanks

        • Re: RhoElements ASP.Net app - first scan works, subsequent scans don't?
          Benedict Kennedy

          Hi Matt,

           

          I have loaded the file onto my unit (stripping out the asp.net code) and scanning multiple times seems to work for me. Just to confirm, is it that the second attempt does scan (i.e. beep) but the code isn't appearing in the page? or is it that the scanner wont activate for the second time? If it is the former, My first guess would be that there is no input box currently selected so the line:

           

          var focused=document.activeElement;

                   focused.value = data; 

           

          wouldn't work. If it is the latter, my other guess would be that if you are pressing either of the "submit" buttons after the first decode, it might be deactivating the scanner as it looks like a POST message (and therefore attempts to navigate). If it is this issue, there are simple ways around the problem.

           

          Best regards,

          Ben

            • Re: RhoElements ASP.Net app - first scan works, subsequent scans don't?

              Ben:

               

              Yes, it is the second attempt. It does scan, I get a beep, but no data.

              The submit button is being pressed after the first decode.

               

              What should I change?

               

              Thanks,

              Matt

                • Re: RhoElements ASP.Net app - first scan works, subsequent scans don't?
                  Benedict Kennedy

                  Hmm, I might be getting a different problem than you are. Would you be able to try this piece of code out, it might solve your problem.

                   

                  function setupScanner()
                  {
                            scanner.decodeEvent = "doScanDecode('%1', '%2', '%6')";
                            scanner.enable();
                  }
                  window.addEventListener('load', setupScanner);
                  

                   

                  If you add that to your script block, this will setup the scanner on page load. As the submit constitutes as a page load, it will hopefully reset the scanner. With this code in place you wont need the scanner meta tag anymore. This solves the problem I am seeing but your issue might be different.

                   

                  I shall look into this further.

                   

                  Regards,

                  Ben

                    • Re: RhoElements ASP.Net app - first scan works, subsequent scans don't?

                      Thanks Ben!

                       

                      Adding your setupScanner() function to my "onload=" which is set in my  <%=str_focus%> variable fixed the issue.

                      I did not have to use the "window.addEventListener('load', setupScanner); "

                       

                      Much appreciated.

                       

                      Matt

                        • Re: RhoElements ASP.Net app - first scan works, subsequent scans don't?
                          Benedict Kennedy

                          That's great news Matt, it looks like my issue might have been slightly different. If you do have any regression of the issue, try using this code instead (remove the window.addEventListener... as appropriate).

                          function resetScanner()
                          {
                                    scanner.decodeEvent = "doScanDecode(%json)";
                                    scanner.enable();
                          }
                          window.addEventListener('load', resetScanner);
                          function doScanDecode(jsonObj)
                          {
                                    if (jsonObj.event != 'Decode')
                                              return;
                          
                                    var focused = document.activeElement;
                                    focused.value = jsonObj.data;
                          }
                          

                           

                          The difference is that it uses the newer JSON format return string. It looks like my issue was something to do with the strange characters in my test barcodes.

                           

                          Glad to hear it's working now. Best regards,

                          Ben