ASP.NET Sample C#

   Minimize

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NBarcode.Writing.Web;

namespace WebApplication1
{
    public partial class Sample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string code = this.TextBox1.Text;
           
            string btypes = this.DropDownList1.Text;
            NBarcode.Writing.Web.BarcodeType barcodeType = BarcodeType.Code128;
            try
            {
                barcodeType = new BarcodeType(btypes);


                this.BarcodeWebControl1.BarcodeType = barcodeType;
               
                this.BarcodeWebControl1.ToolTip = this.TextBox2.Text;
                this.BarcodeWebControl1.BarcodeStyle.BarHeight = int.Parse(this.TextBox3.Text);
                this.BarcodeWebControl1.BarcodeStyle.WideNarrowRatio = int.Parse(this.TextBox4.Text);
                this.BarcodeWebControl1.BarcodeStyle.SetDirty();
                this.BarcodeWebControl1.Code = this.TextBox1.Text;
                this.BarcodeWebControl1.SupplementData = this.TextBox5.Text;

                this.Label1.Text = this.BarcodeWebControl1.BarcodeType.ToString() + "[" + this.BarcodeWebControl1.Code +
                                   "]";

            }
            catch (Exception ex)
            {
                this.Label1.Text = ex.Message;
            }
        }
    }
}