The quick start guides you through the steps of adding different barcodes to your MVC web application and display them as the output. In the following example, we have added three barcodes, namely Codabar, Code39 and Gs1-128, and these barcodes can be displayed using the Codabar, Code39 and Gs1_128 barcode classes respectively. Similarly, you can use any of the 26 barcodes supported by the Barcode control. For the complete list of supported barcodes, see Barcode Encodings.
To accomplish this, follow these steps:
Create a new MVC application using the ComponentOne or VisualStudio templates. For more information about creating an MVC application, see Configuring your MVC Application topic.
To add the Barcode control to your application, add C1.Web.MVC reference and follow these steps:
BarcodeController
).Sale.cs |
Copy Code
|
---|---|
public ActionResult Index() { return View(); } |
BarcodeController.
Index()
.Index.cshtml |
Copy Code
|
---|---|
@model object[] <table class="table"> <thead> <tr> <th>BarCodes</th> </tr> </thead> <tbody> <tr> <td> <div> <div style="font-weight:bold">Codabar</div> <div>@Html.C1().Codabar().Value("A15126893B").AutoWidthZoom(2)</div> </div> <br /> <div> <div style="font-weight:bold">Code39</div> <div>@Html.C1().Code39().Value("A1312BCV").AutoWidthZoom(2)</div> </div> <br /> <div> <div style="font-weight:bold">Gs1_128</div> <div>@Html.C1().Gs1_128().Value("GS1128Demo").AutoWidthZoom(2)</div> </div> </td> </tr> </tbody> </table> |