Link to home
Start Free TrialLog in
Avatar of apocalypse910
apocalypse910

asked on

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)
Avatar of divinewind80
divinewind80

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.
ASKER CERTIFIED SOLUTION
Avatar of divinewind80
divinewind80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apocalypse910

ASKER

That is Perfect.. Thank you very much for your help.