$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
How to Build QR Code Barcode Using C#
Home > How to > Barcode QRCode

How to Build QR Code Barcode Using C#

We have explained the major QR Code properties and demonstrated the sample ASP.NET codes in details in the page - how to create QR Code within ASP.NET application, while here, we are about to show users the step by step guides on how to create and specify QR Code within C#.NET project.

How to Set QR Code Type with C#

PerBarcode1.Type = BarcodeType.QRCode;

How to Set QR Code Text with C#

PerBarcode1.Text = "123456789";

How to Set Particular Properties of QR Code with C#

PerBarcode1.QRCodeSettings.ErrorCorrectionLevel = Modes.ErrorCorrectionLevel.L;
PerBarcode1.QRCodeSettings.Version = 1;
int dots = version * 4 + 25;
intmaxLength = Math.Min(width, height);
PerBarcode1.QRCodeSettings.DotSize = maxLength / dots;
Generally speaking, the above QR Code properties can be set and defined in PerBarcode1.PreRender project.
protectedvoidPage_Load(object sender, EventArgs e)
{
PerBarcode1.PreRender += newEventHandler(PerBarcode1_PreRender);

}

protectedvoid PerBarcode1_PreRender(object sender, EventArgs e)
{
PerBarcode1.Type = BarcodeType.QRCode;
PerBarcode1.Text = "123456789";
PerBarcode1.Width = 371;
PerBarcode1.Height = 371;
PerBarcode1.QRCodeSettings.ErrorCorrectionLevel = Modes.ErrorCorrectionLevel.L;
PerBarcode1.QRCodeSettings.Version = 1;
PerBarcode1.QRCodeSettings.DotSize = Math.Min(int.Parse(txtDotSize.Text),
CalculateDotSize(PerBarcode1.QRCodeSettings.Version, (int)PerBarcode1.Width, (int)PerBarcode1.Height));
}

protectedstaticintCalculateDotSize(int version, int width, int height)
{
int dots = version * 4 + 25;
intmaxLength = Math.Min(width, height);

returnmaxLength / dots;
}

QR Code Settings Within C#.NET Project

For better guiding users, we still provides the brief introductions of most common QR Code settings collection.
  • Error Correction Level - To be specific, there are four available values to this property, they are: L(Low), M(Medium), Q(Quartile), H(High), and these values allow for 7%, 15%, 25% and 30% recovery of symbol code words. In addition, if we choose a higher version of error correction, the barcode can dedicate a larger portion of modules for error correction.
  • Application Indicator - We can apply this property to add additional data to the FNC1 data. And a note here that is this property is only applicable with FNC1Mode.FNC1SecondPosition. And the acceptable data for this property is in the range {a-z}], {[A-Z} and {00-99}.
  • Mode - Four kinds of data set and characters are available for this property - numeric data (digits 0 - 9); alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : ); byte data (default: ISO/IEC 8859-1); and Kanji characters.
  • Version - The available value of this property is integer value, which can range from 1 to 40. And we can freely choose which version to be used. Usually, higher-version QR codes are used do accommodate larger amounts of data.
  • DotSize - We can use this property to specify size of the QR Code barcode dots in pixels. Use this to achieve sharp rendered QR Code. You can use this in combination with Width="" and Higth="" and the QR will be sized according to the number of its dots. If you set DotSize to zero, the QR symbol will be resized to fill up the Width and Height.
ASP.NET AJAX UI Controls