Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to display the detail in gridview when i scan a barcode through a barcode machine which is connected through my usb.My Textchange event is not getting fired when i get the barcode text in textbox.This is what i have done so far.

<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" ontextchanged="TextBox1_TextChanged"
>

C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
{

    string voucher = TextBox1.Text;

}



Any help would be appreciated.
Posted
Updated 24-Aug-13 7:08am
v3

1 solution

You don't "trigger" an event. You simply show the scanner the barcode and it does the work.

Depending on the interface your barcode scanner is exposed on, probably as a serial port, you end up reading the barcode from the interface and do whatever you need to do with the data.

Consult the documentation on the barcode scanner to see how it's exposed to your code.
 
Share this answer
 
Comments
Amit Karyekar 24-Aug-13 12:39pm    
i wanted to know how to get the barcode text in textbox when i scan it?
Dave Kreskowiak 24-Aug-13 13:35pm    
That depends ENTIRELY on the interface your barcode scanner exposes itself on. Consult the documentation on the scanner to find out what that is.

It can be either a "keyboard wedge", or on a COM port (serial), or there are even scanners that work on Ethernet.
Amit Karyekar 24-Aug-13 22:48pm    
Till now i am getting the text of the scanned barcode in the textbox.Now the problem is that textchange event doesnt get fired after textbox is filled.I have to press enter for the event to be fired.
Dave Kreskowiak 25-Aug-13 9:48am    
That would be because you didn't configure the barcode scanner to hit [ENTER]. Usually, there are configuration options you can give the scanner to tell it to prepend to the beginning and/or append to the end of the barcode any sequence of characters you want, including [ENTER].
Dave Kreskowiak 25-Aug-13 9:49am    
Again, READ the documentation on the scanner! It would have told you this!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900