In
this article I am going to explain how to generate QR code image using Google
Chart API in asp.net.
In
the previous article I have explained how to populate dropdownlist with monthsname in asp.net, how to get all countries list using system.globalization andbind to dropdownlist in asp.net, how to print a web form (webpage) in asp.netusing C# and VB.net, how to generate and display QR code image using QR Codelibrary in asp.net and how to filter the record using Alphabets pager inasp.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
No comments:
Post a Comment