ASP.NET: Generate QR code image using Google Chart API - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

ASP.NET: Generate QR code image using Google Chart API

In this article I am going to explain how to generate QR code image using Google Chart API in asp.net.


Description:
QR code image will be generating using Google chart API with a url get request.


Implementation:
HTML Markup:
<fieldset style="width:30%">
        <legend>Generate QR Code using Google API</legend>
        <table>
        <tr><td>Enter URL OR Text:</td><td><asp:TextBox ID="txturl" runat="server"></asp:TextBox></td></tr>
        <tr><td colspan="2"><asp:Image runat="server" ID="QRImage"/></td></tr>

        <tr><td></td><td></td></tr>
        <tr><td></td><td><asp:Button ID="btnsubmit" runat="server" Text="Generate QR Code" onclick="btnsubmit_Click" /></td></tr>
        </table>
        </fieldset>

Generate QR code
On Button click write the below given code.
C# code:
protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            var url = "http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=" + txturl.Text + "";
            QRImage.ImageUrl = url;
        }
        catch(Exception ex)
        {
        }
    }

VB.net Code:
Protected Sub btnsubmit_Click(sender As Object, e As System.EventArgs) Handles btnsubmit.Click
        Try
            Dim url = "http://chart.apis.google.com/chart?cht=qr&chs=150x150&chl=" + txturl.Text + ""
            QRImage.ImageUrl = url
        Catch ex As Exception
        End Try
    End Sub


What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon