Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1154
  • Last Modified:

Preventing AutoSubmit when using Barcode Reader with ASP.net Page

I am building an inventory entry page in ASP.net for my store. I want to allow some data to be entered from a Bar code reader.  Using the bar code scanner with my current code works, it enters the data to the field correctly. Currently, however the action of scanning the item is equivalent to typing the data and pressing the enter key. This triggers the submit event on the page.  How do i prevent this from happening? Thanks in advance for the help


Relevant control code:
Line where barcode would be scanned...
<asp:TextBox ID="C_Alias" TextMode="SingleLine" runat="server" Width="99%" Text=""></asp:TextBox>

Submit button...
 <asp:Button ID="C_Submit" runat="server" Text="Add Item" OnClick="C_Submit_Click"></asp:Button>

Submit Function Header...
    Protected Sub C_Type_Change(ByVal sender As Object, _
            ByVal e As System.EventArgs)
0
apocalypse910
Asked:
apocalypse910
  • 2
1 Solution
 
divinewind80Commented:
You have a couple of solutions you can use:

1) Capture the "Enter" key with Javascript and disable it.  Often the barcode scanner simulates "Enter" when the barcode is read fully.
2) Set the barcode scanner to not hit "Enter" as the suffix.  Some barcode scanners can be set to do this... others cannot.

I've used both of these techniques with success.

Hope that helps.
0
 
divinewind80Commented:
The javascript to catch the "Enter' key is as follows:

 function handleKeyPress(evt) {
  var nbr = (window.event)?event.keyCode:evt.which;
  if(nbr==13){
your code here

  }
 }
 document.onkeydown= handleKeyPress

Look up an ASCII key code table on Google to find more info on it.
0
 
apocalypse910Author Commented:
That is Perfect.. Thank you very much for your help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now