We help IT Professionals succeed at work.

Preventing AutoSubmit when using Barcode Reader with ASP.net Page

Last Modified: 2009-02-11
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)
Watch Question

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.
Unlock this solution and get a sample of our free trial.
(No credit card required)


That is Perfect.. Thank you very much for your help.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.