Click here to Skip to main content
Licence MIT
First Posted 11 Dec 2009
Views 12,875
Downloads 311
Bookmarked 24 times

Displaying Binary Images and Barcode

By RMostafa | 11 Dec 2009
This is an update to the RbmBinaryImage control - to display barcodes.

1
1 vote, 12.5%
2
1 vote, 12.5%
3
1 vote, 12.5%
4
5 votes, 62.5%
5
4.16/5 - 8 votes
μ 4.16, σa 2.13 [?]

Introduction

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.

Background

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.

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

Finally

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

License

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

About the Author

RMostafa

Software Developer (Senior)
Code Republic
Egypt Egypt

Member
My name is Ramy Mostafa. I’m From Alexandria,Egypt currently living in Cairo,Egypt. I have graduated from the Arab Academy for Science and Technology and Maritime Transport with a BS. in Computer Science, also I’m a Microsoft Certified Professional since 2004. I have extensive professional experience as a developer and expertise in OOP, OOA, OOD and problem solving techniques. Currently I’m working as a senior developer in Code Republic a European owned and directed software outsourcing company based in Egypt with liaison offices in Europe.
 
Also I’m a huge fan of Al-Ahly Club, I like reading, swimming and diving -used to play in the national team of finswimming in Egypt- worth to mention that I like reading Ragol El Mostahel and Malaf el Mostakbal (a huge fan of it actually Smile | :) )
 
To reach me, you can either send me an e-mail at ramy.mostafa@gmail.com or call at (002) 010 3332382

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralBarCode Image Format PinmemberZ@clarco0:13 23 Nov '10  
Question[My vote of 2] Article Intro Purpose Pinmemberstixoffire3:30 15 Dec '09  
AnswerRe: [My vote of 2] Article Intro Purpose PinmemberRMostafa3:34 15 Dec '09  
GeneralRe: [My vote of 2] Article Intro Purpose Pinmemberstixoffire3:52 15 Dec '09  
So you are saying this is simply an image handler that also allows you to display the barcode of a represented image ?
 
I understand about getting an image from SQL database in Binary and translating that into Image - only a few lines of code there. If Null display other not too difficult there either.. I do not need a separate handler for this - as I can D/L from DB and resize on the fly. If I can remember my code correctly I do this in the Eval statement on codebehind as I grab each image.. I use a reference to a DLL in my code to do this.
 
But where does the Barcode come in ?
And why do I need to add that - is this just combining functionality into one DLL ?
 
I do have a pretty complete Barcode DLL library - that I found on codeproject - that renders several different barcode formats as an image of the Barcode ..
 
Again this still leaves me of a question for your article..
GeneralRe: [My vote of 2] Article Intro Purpose PinmemberRMostafa4:50 15 Dec '09  
GeneralArtice needs emprovment Pinmemberemilio_grv6:18 11 Dec '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.5.120210.1 | Last Updated 11 Dec 2009
Article Copyright 2009 by RMostafa
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid