Sometimes we need to display barcodes on HTML pages. Today to share with you in barcode Professional, how to display barcodes on HTML.
Steps:
- Open it. NET development tools, such as Visual Studio. Net. Create a new ASP. NET Web Application
- For the barcode to be displayed on the HTML page, we need to create an ASP. WebForm and HTTP Handler.
- Add references to Barcode Professional
- In the barcodegen.aspx ' s code file, add the following space to name the reference
Vb
Imports Neodynamic.WebControls.BarcodeProfessional
C#
using Neodynamic.WebControls.BarcodeProfessional;
- Barcodegen.aspx page will receive the encoded parameters through the string query, in the Page_Load event, you can use barcode Professional to generate barcodes, refer to the following code:
Vb
DimBcp as NewBarcodeprofessionalbcp.code= Request.QueryString ("Code") bcp. Symbology=symbology.code128DimBarcodeimage as Byte() =bcp. Getbarcodeimage (System.Drawing.Imaging.ImageFormat.Gif)If(Barcodeimage is Nothing) ThenResponse.End ()Elseresponse.clear () Response.ContentType="Image/gif"Response.BinaryWrite (Barcodeimage) response.end ()End If
C#
Barcodeprofessional bcp =Newbarcodeprofessional (); bcp. Code= request.querystring["Code"];bcp. Symbology=symbology.code128;byte[] Barcodeimage =bcp. Getbarcodeimage (System.Drawing.Imaging.ImageFormat.Gif);if(Barcodeimage = =NULL) Response.End ();Else{response.clear (); Response.ContentType="Image/gif"; Response.BinaryWrite (Barcodeimage); Response.End ();}
- Add an HTML page that can be named barcodetest.htm, where script code can be used to add dynamic barcodes. Reference code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
- In this way, you create an ASP. NET Web application, open barcodetest.htm, enter the code, and click the "View Barcode" button to view the generated barcode.
original translation from BarcodeBarcode Professional for ASP. NET use Tutorial: HTML page Display barcode