QRCode HtmlHelper Overview

The Telerik UI QRCode HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI QRCode widget.

The QRCode generates Canvas and Scalable Vector Graphics (SVG) images that represent Quick Response (QR) codes.

QR codes take a piece of information from a transitory media, place it into the cell phone, and enable the cell phone to quickly read these generated images. All graphics are rendered on the client by using Canvas or SVG.

Basic Configuration

  1. Make sure you followed all the steps from the introductory article on Telerik UI for ASP.NET MVC.
  2. Create a new action method which renders the view.

    public ActionResult Index()
    {
        return View();
    }
    
  3. Add a QRCode.

        <%: Html.Kendo().QRCode()
            .Name("qrcode") // The name of the QRCode is mandatory. It specifies the "id" attribute of the widget.
            .Value("#ff0000") // Set the value of the QRCode.
        %>
    
        @(Html.Kendo().QRCode()
            .Name("qrcode") // The name of the QRCode is mandatory. It specifies the "id" attribute of the widget.
            .Value("#ff0000") // Set the value of the QRCode.
        )
    
  4. Choose the appropriate correction level and/or encoding.

        <%: Html.Kendo().QRCode()
            .Name("qrcode")
            .ErrorCorrection(QRErrorCorrectionLevel.H)
            .Encoding(QREncoding.ISO_8859_1)
            .Value("foo")
        %>
    
        @(Html.Kendo().QRCode()
            .Name("qrcode")
            .ErrorCorrection(QRErrorCorrectionLevel.H)
            .Encoding(QREncoding.ISO_8859_1)
            .Value("foo")
        )
    

Referencing Existing Instances

To reference an existing QRCode instance, use the jQuery.data() configuration option. Once a reference is established, use the QRCode client-side API to control its behavior.

// Place the following after the declaration of the QRCode for ASP.NET MVC.
<script>
    $(function() {
        // The Name() of the QRCode is used to get its client-side instance.
        var qrcode = $("#qrcode").data("kendoQRCode");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article