QR Code Generator in ASP.NET

Simple Approach for QR Code Generation in ASP.Net using Google API
 
Though there are many solutions for QR Code generation in ASP.Net, all of it requires referring to 3rd party dlls. But there is a very simple alternative through which we can create a QR code generator in ASP.Net within minutes without referring to any 3rd party dlls.

Let's create a ASP.Net web application with a text box, image control and Button as shown: 
  1. <asp:TextBox runat="server" ID="txtData"></asp:TextBox>  
  2.    <asp:Button runat="server" ID="btnClickMe" Text="Click Me" OnClick="btnClickMe_Click" />  
  3. <br />  
  4. <asp:Image runat="server" ID="ImgQrCode" Height="160" Width="160" /> 
In the button click event, generate the URL for the API with the data entered in the text box and size of the image control and set it to the image control's image URL property 
  1. protected void btnClickMe_Click(object sender, EventArgs e)  
  2. {  
  3.    ImgQrCode.ImageUrl = "https://chart.googleapis.com/chart?   cht=qr&chl=" + WebUtility.HtmlEncode(txtData.Text) + "&choe=UTF-8&chs=" + ImgQrCode.Height.ToString().Replace("px""") + "x" + ImgQrCode.Width.ToString().Replace("px""");  

 Result
 
 
 
That's it.
 
More details in the following link.
Ebook Download
View all
Learn
View all