How to generate barcode in | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

How to generate barcode in

In this article I am going to explain how to generate barcode in

How to generate barcode in

Barcode provides asset and security tracking. To generate the barcode I am using ONbarcodeDLL.

Add a webform to project. Download the Onbacode DLL and add it to project.

HTML markup:
  <fieldset style="width:30%">
        <legend>Generate BAR Code Example</legend>
        <tr><td>Enter Text/Value:</td><td><asp:TextBox ID="txtvalue" runat="server"></asp:TextBox></td></tr>       
        <tr><td></td><td><asp:Button ID="btnsubmit"
            runat="server" Text="Generate BAR Code"/></td></tr>
            <tr><td colspan="2"><asp:Image runat="server" ID="imgbarcode" /></td></tr>

Import the namespace

C# Code :
using System.Drawing;
using System.Drawing.Imaging;
using OnBarcode.Barcode; code:
Imports OnBarcode.Barcode
Imports System.Drawing
Imports System.Drawing.Imaging

On button click write the below given code:

C# Code
protected void btnsubmit_Click(object sender, EventArgs e)
            Linear barcode = new Linear();
            barcode.Type = BarcodeType.CODE39;
            barcode.Data = txtvalue.Text;
            imgbarcode.ImageUrl = "image/barcode.gif";
        catch (Exception ex)
    } code:
   Protected Sub btnsubmit_Click(sender As Object, e As EventArgs) Handles btnsubmit.Click
            Dim barcode As New Linear
            barcode.Type = BarcodeType.CODE39
            barcode.Data = txtvalue.Text
            imgbarcode.ImageUrl = "image/barcode.jpg"
        Catch ex As Exception

        End Try
    End Sub

Build and run the project.

Post a Comment



Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget