Neodynamic Barcode Professional for WPF (any version)
Microsoft .NET Framework 3.5 (ASP.NET 3.5) or greater
Microsoft Visual Studio 2008
Microsoft Visual Web Developer 2008 Express Edition (VWD)
This walkthrough illustrates how easily you can use Barcode Professional for WPF in ASP.NET Web Applications. Barcode Professional for WPF leverages new WPF Drawing API generating high quality barcodes. Barcode Professional for WPF features raster barcode image generation which is useful in scenarios like ASP.NET Web Applications that need to display/deliver barcode to Internet Browsers.
During the course of this walkthrough, you will accomplish the following activities:
Please follow these steps:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Barcode Professional for WPF in ASP.NET</title> <style type="text/css"> .newStyle1 { font-family: arial, Helvetica, sans-serif; } </style> </head> <body> <form id="form1" runat="server"> <div class="newStyle1"> <h3>Barcode Professional for WPF in ASP.NET</h3> <br /> Enter Value to Encode: <br /> <asp:TextBox ID="TextBox1" runat="server" Width="264px"> </asp:TextBox><asp:Button ID="Button1" runat="server" Text="Barcode Now!" onclick="Button1_Click" /> <br /> <br /> <asp:Image ID="Image1" runat="server" Visible="false" /> </div> </form> </body> </html>
If (Me.TextBox1.Text.Length > 0) Then
Me.Image1.ImageUrl = "~/BarcodeGen.ashx?code=" + Me.TextBox1.Text
Me.Image1.Visible = True
End If
if (this.TextBox1.Text.Length > 0)
{
this.Image1.ImageUrl = "~/BarcodeGen.ashx?code=" + this.TextBox1.Text;
this.Image1.Visible = true;
}
<%@ WebHandler Language="VB" Class="BarcodeGen" %>
Imports System
Imports System.Web
Imports Neodynamic.WPF
Public Class BarcodeGen : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
'Get value to encode from querystring
Dim valueToEncode As String = context.Request("code")
'Create BarcodeBuilder object
Dim bc As New BarcodeBuilder()
'Set barcode standard
bc.Symbology = Symbology.Code128
'Set value to encode
bc.Code = valueToEncode
'Set output image settings
bc.ImageSettings.Dpi = 96
bc.ImageSettings.ImageFormat = ImageFormat.Gif
'Generate barcode
context.Response.ContentType = "image/gif"
context.Response.BinaryWrite(bc.GetBarcodeImageBinary())
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
<%@ WebHandler Language="C#" Class="BarcodeGen" %>
using System;
using System.Web;
using Neodynamic.WPF;
public class BarcodeGen : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//Get value to encode from querystring
string valueToEncode = context.Request["code"];
//Create BarcodeBuilder object
BarcodeBuilder bc = new BarcodeBuilder();
//Set barcode standard
bc.Symbology = Symbology.Code128;
//Set value to encode
bc.Code = valueToEncode;
//Set output image settings
bc.ImageSettings.Dpi = 96;
bc.ImageSettings.ImageFormat = ImageFormat.Gif;
//Generate barcode
context.Response.ContentType = "image/gif";
context.Response.BinaryWrite(bc.GetBarcodeImageBinary());
}
public bool IsReusable {
get {
return false;
}
}
}
Sample Files Download
Here are the VB.NET and C# versions of this sample. Please download the zip file and extract it.
Remember to download and install Barcode Professional for WPF in order to reproduce this sample demo.
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.