VintaSoft Barcode .NET SDK v12.0 for .NET Framework
In This Topic
    Get barcode image in ASP.NET WebForms
    In This Topic

    A barcode image in an ASP.NET WebForms application can be generated synchronously or asynchronously. The modern web applications are functioning asynchronously because this allows to prevent blocking of the application UI, so the asynchronous generation of barcode is more preferable.

    1. Asynchronous barcode generation

    The process of asynchronous barcode generation can be divided into the following steps:
    1. Client-side: ASP.NET WebForms application sends an asynchronous request to a web service
    2. Server-side: The web service generates a barcode and sends the results to the application
    3. Client-side: The application processes the generated barcode

    Client-side of ASP.NET WebForms application

    The WebBarcodeWriterJS class, from Vintasoft.Barcode.js file, can be used on a client-side of ASP.NET WebForms application for generating of barcode image.
    The WebBarcodeWriterJS class allows to:
    Important: JQuery (version 1.11 or higher) and Vintasoft.Shared.js file are necessary for correct work of Vintasoft.Barcode.js file.

    Example: Here is JavaScript example that demonstrates how to generate an image of DataMatrix barcode:
    // create service that allows to write barcode
    var barcodeService = new Vintasoft.Shared.WebServiceControllerJS("/Handlers/Barcodes/BarcodeHandler.ashx");
    // create the barcode writer
    var barcodeWriter = new Vintasoft.Barcode.WebBarcodeWriterJS(barcodeService);
    // specify that DataMatrix barcode must be generated
    barcodeWriter.get_Settings().set_BarcodeType(new Vintasoft.Barcode.Web2DBarcodeTypeEnumJS("DataMatrix"));
    // send an asynchronous request for getting barcode image as Base64 string
    barcodeWriter.getBarcodeAsBase64Image(__writeBarcode_success, __writeBarcode_failed);
    // Barcode image is generated successfully.
    function __writeBarcode_success(data) {
        if (data.success) {
            var imageAsBase64string = data.barcode;
            document.getElementById("barcodeImage").src = imageAsBase64string;
        else {
    // Barcode generation is failed.
    function __writeBarcode_failed(data) {
        // show information about error

    Server-side of ASP.NET WebForms application

    Depending on application architecture the web service, which generates barcodes, can be based on WCF service or HTTP handler.
    SDK provides the following ready-to-use web services:
    Important: Vintasoft.Barcode.dll, Vintasoft.Shared.dll and Vintasoft.Shared.Web.dll assemblies are necessary for correct work of Vintasoft.Barcode.Web.WcfServices.dll or Vintasoft.Barcode.Web.HttpHandlers.dll assembly.

    Here is a code snippet that demonstrates how in ASP.NET WebForms application create HTTP handler:
    namespace AspNetBarcodeDemos.Handlers.Barcodes
        // HTTP handler for reading and writing barcodes.
        public class BarcodeHandler : Vintasoft.Barcode.Web.HttpHandlers.VintasoftBarcodeHandler
            public BarcodeHandler()
                : base()

    2. Synchronous barcode generation

    The process of synchronous barcode generation can be divided into the following steps:
    1. Client-side: ASP.NET application sends request to ASPX page
    2. Server-side: Page executes its server code, generates a barcode image and sends new page layout to the application
    3. Client-side: The application receives the new ASPX page layout and refreshes the page

    Usage of AJAX technology allows to refresh a part of page instead of the whole page.

    3. Demo applications

    The AspNetBarcodeDemos project (can be found in distributive package of VintaSoft Barcode .NET SDK) contains the BarcodeWriterDemo, which demonstrates how to implement an asynchronous generation of barcode image using the web service based on HTTP handler.

    Also the AspNetBarcodeDemos project contains the SyncBarcodeWriterDemo, which demonstrates how to implement a synchronous generation of barcode on ASPX page.