Home
We need your feedback!

Bytescout.BarCode Reader SDK for .NET screenshots

Barcode reader test application
Barcoder reading ASP.NET sample  application
Sample ASP.NET application utilizing BarCode Reader SDK  to read barcode from uploaded image Sample Pocket PC application utilizing BarCode Reader SDK  to read barcode from uploaded image
Subscribe to Our Bi-Monthly Newsletter (tips, new releases, specials):
 Subscribe in a reader
 PRODUCTS  |  DOWNLOAD  |  PURCHASE  |  SUPPORT  |  TESTIMONIALS   |  NEWS  | 

How to upload image in ASP.NET and read barcode value from this image using
Bytescout.BarCode Reader SDK
for .NET 2.00 or higher

Download Free Trial Buy Now More Information
Shop Safely: BarCode Reader SDK comes with a 30-DAY UNCONDITIONAL MONEY-BACK GUARANTEE

The tutorial demonstrates how to upload photo image with barcode and then recognize barcode value using BarCode Reader SDK in ASP.NET application

The following sample demonstrates how to upload image with barcode and then read barcode from it using Bytescout BarCode Reader SDK for .NET

You can find full source code of this sample in \Examples\Advanced Examples\ folder of Bytescout BarCode Reader SDK installation.

ASP.NET application (design mode):
ASP.NET design mode application screenshot

Running barcode recognition ASP.NET application:
net barcode reader

1) Visual Basic in ASP.NET

Default.aspx:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebTestVB._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Web Barcode Reader Tester (VB)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
Click browse button to upload an image<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button ID="UploadButton" runat="server" OnClick="UploadButton_Click" Text="Upload file" />
<br />
<br />
<asp:Label ID="UploadStatusLabel" runat="server" Text=""></asp:Label>
<br />
<asp:ListBox ID="ListBox1" runat="server" Visible="False"></asp:ListBox><br />
<br />
<asp:Image ID="Image1" runat="server" Visible="False" /></div>

</div>
</form>
</body>
</html>

Default.aspx.vb:

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Drawing
Imports System.Collections.Generic

Imports Bytescout.BarCodeReader

Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim savePath As String = "\uploads\"

If FileUpload1.HasFile Then
Dim fileName As String = FileUpload1.FileName
savePath += fileName
FileUpload1.SaveAs(Server.MapPath(savePath))

Dim bitmap As Bitmap = Nothing
Try
bitmap = New Bitmap(FileUpload1.FileContent)
Catch generatedExceptionName As System.Exception
End Try

If bitmap Is Nothing Then
UploadStatusLabel.Visible = True
UploadStatusLabel.Text = "Your file is not an image"
Image1.Visible = False
ListBox1.Visible = False
Else
UploadStatusLabel.Visible = False
Image1.ImageUrl = savePath
Image1.Visible = True
ListBox1.Items.Clear()
ListBox1.Visible = True
findBarcodes(Server.MapPath(savePath))
If ListBox1.Items.Count = 0 Then
ListBox1.Items.Add("No barcodes found")
End If
End If
Else
' Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to upload."
End If
End Sub

Private Sub findBarcodes(ByVal fileName As String)
Dim reader As New Reader(fileName)
For Each barcode As FoundBarcode In reader.FoundBarcodes
ListBox1.Items.Add([String].Format("{0} : {1}", barcode.Type, barcode.Value))
Next
End Sub

End Class

2) Visual C# in ASP.NET

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebTestSharp._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Web Barcode Reader Tester (C#)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Click browse button to upload an image<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
<asp:Button id="UploadButton"
Text="Upload file"
OnClick="UploadButton_Click"
runat="server">
</asp:Button>
<br />
<br />
<asp:Label id="UploadStatusLabel" Text="" runat="server"></asp:Label>
<br />
<asp:ListBox ID="ListBox1" runat="server" Visible="False"></asp:ListBox><br />
<br />
<asp:Image ID="Image1" runat="server" Visible="False" /></div>
</form>
</body>
</html>

Default.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Collections.Generic;

using Bytescout.BarCodeReader;

namespace WebTestSharp
{
public partial class _Default : System.Web.UI.Page
{
protected void UploadButton_Click(object sender, EventArgs e)
{
String savePath = @"\uploads\";

if (FileUpload1.HasFile)
{
String fileName = FileUpload1.FileName;
savePath += fileName;
FileUpload1.SaveAs(Server.MapPath(savePath));

Bitmap bitmap = null;
try
{
bitmap = new Bitmap(FileUpload1.FileContent);
}
catch (System.Exception)
{
}

if (bitmap == null)
{
UploadStatusLabel.Visible = true;
UploadStatusLabel.Text = "Your file is not an image";
Image1.Visible = false;
ListBox1.Visible = false;
}
else
{
UploadStatusLabel.Visible = false;
Image1.ImageUrl = savePath;
Image1.Visible = true;
ListBox1.Items.Clear();
ListBox1.Visible = true;
findBarcodes(Server.MapPath(savePath));
if (ListBox1.Items.Count == 0)
ListBox1.Items.Add("No barcodes found");
}
}
else
{
// Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "You did not specify a file to upload.";
}
}

private void findBarcodes(string fileName)
{
Reader reader = new Reader(fileName);
foreach (FoundBarcode barcode in reader.FoundBarcodes)
ListBox1.Items.Add(String.Format("{0} : {1}", barcode.Type, barcode.Value));
}
}
}

Download Free Trial Buy Now More Information
Shop Safely: BarCode Reader SDK comes with a 30-DAY UNCONDITIONAL MONEY-BACK GUARANTEE

First steps tutorials:

Advanced Examples (Visual Basic and C#):

HOME  |  CONTACT US

Copyright © ByteScout, 2003-2010. Privacy Statement
Microsoft®, Windows®, Windows 2000®, Windows Server®, Windows Vista®, Internet Explorer®, .NET Framework®, ActiveX®, Visual Basic®, Visual C#®, ASP®, ASP.NET®, Excel®, PowerPoint®, are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Adobe®, Flash® and Acrobat® are registered trademarks of Adobe Systems, Incorporated. Mozilla®, Firefox® and the Mozilla and Firefox Logos are registered trademarks of the Mozilla Foundation. Other product names or brandnames used herein are for identification purposes only and might be trademarks or registered trademarks of their respective companies. We disclaim any and all rights to those marks.