Click here to Skip to main content
13,260,383 members (43,820 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 11 Dec 2009

Displaying Binary Images and Barcode

, 11 Dec 2009
Rate this:
Please Sign up or sign in to vote.
This is an update to the RbmBinaryImage control - to display barcodes.


One of my friends was asking me how to display barcodes in ASP.NET. There is a great Open Source code written by Bart De Smet which can return a bar code image from a bar code string; you could see his article here. I have just added to it a small option of whether or not to display the code under the bar code. The library returns an Image. I thought, adding the display of the bar code from the bar code string value to RBMBinaryImage would be cool.


In the last version of RBMBinaryImage on CodeProject, some people pointed out that the control worked in Visual Studio perfectly but not well on some servers. I place here a solution for this problem posted by Louis, on of the control users on my site for the RBMBinaryImage, for users using the old version.

  1. Open IIS and open the properties for the website you want the handler to work for.
  2. Open Handler mappings and select a file extension which is served by ASP.NET, like .aspx, and click Edit.
  3. Copy the file that's used over there (should be %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll).
  4. Close the dialog and click Add Script Map... to add a new one. Put the copied value in the right textbox, and fill in .rbm as the extension you want to be handled - uncheck the option "Verify that file exists" when mapping the application extensions.
  5. Next, close all open boxes by clicking OK, and you should be ready to go.

In the new version of the control, we can display a barcode as an image. Shown below is a screenshot:

Using the code

The idea was simple since, the Code39 library returns an Image object, so I only got its bytes and passed it to the ImageContent property, which is then rendered in the image. For more information on how the binary image display works in RBMBinaryImage, please see the post here. Again, the usage of the control is very easy. To display the barcode, you only need to set the PrintBarcode property to true, and pass to the BarCodeValue the barcode. As you can see below, the DisplayThumbnail property is still being applied on the bar code.

<Rbm:RbmBinaryImage ID="RbmBinaryImage2" runat="server" 

    PrintBarcode="true"  BarCodeValue='<%# Eval("BarCode") %>' 

    DisplayThumbnail="true"   ThumbnailSize="160" 

    EmptyImageUrl="images/NoPhoto.JPG" />

I have made a change to the HttpHandler to be with the extension .ashx instead of .rbm, to be standard compliant.

  <add verb="GET" path="__RbmImageHandler.ashx" type="RbmControls.RbmImageHandler"/>


You can download the latest version of the project from here.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Software Developer (Senior)
Egypt Egypt
Fun Coder Smile | :) My Job is my Hobby Smile | :)

You may also be interested in...

Comments and Discussions

GeneralBarCode Image Format Pin
Z@clarco23-Nov-10 0:13
memberZ@clarco23-Nov-10 0:13 
Question[My vote of 2] Article Intro Purpose Pin
stixoffire15-Dec-09 3:30
memberstixoffire15-Dec-09 3:30 
AnswerRe: [My vote of 2] Article Intro Purpose Pin
RMostafa15-Dec-09 3:34
memberRMostafa15-Dec-09 3:34 
GeneralRe: [My vote of 2] Article Intro Purpose Pin
stixoffire15-Dec-09 3:52
memberstixoffire15-Dec-09 3:52 
GeneralRe: [My vote of 2] Article Intro Purpose Pin
RMostafa15-Dec-09 4:50
memberRMostafa15-Dec-09 4:50 
GeneralArtice needs emprovment Pin
emilio_grv11-Dec-09 6:18
memberemilio_grv11-Dec-09 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 11 Dec 2009
Article Copyright 2009 by rmostafa
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid