使用asp.net C#生成qr代码(Web表单) [英] generating qr code using asp.net C# (web form)

查看:102
本文介绍了使用asp.net C#生成qr代码(Web表单)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何专家都可以帮忙吗?



 受保护  void  bn_create_Click( object  sender,EventArgs e)
{
字符串 url = tb_content.Text;
QRCodeEncoder enc = new QRCodeEncoder();
Bitmap qrcode = enc.Encode(url);

}









我可以使用Windows窗体,但不是Web窗体。因为网上没有图片框,任何人都可以帮我完成这些代码吗?我正在使用消息工具包。



如果你有任何其他想法/帮助它将拯救我的生命...

解决方案

请查看此视频。这对你有用。


查看这段代码片段。

它可以帮到你。



 BarcodeLib.Barcode.QRCode barcode =  new  BarcodeLib.Barcode.QRCode(); 
barcode.Data = 123456789012;

barcode.ModuleSize = 3 ;
barcode.LeftMargin = 0 ;
barcode.RightMargin = 0 ;
barcode.TopMargin = 0 ;
barcode.BottomMargin = 0 ;

barcode.Encoding = BarcodeLib.Barcode.QRCodeEncoding.Auto;
barcode.Version = BarcodeLib.Barcode.QRCodeVersion.V1;
barcode.ECL = BarcodeLib.Barcode.QRCodeErrorCorrectionLevel.L;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

// 此处有更多条形码设置

// 将条形码图像保存到系统中
barcode.drawBarcode( c://barcode.png);

// 生成条形码&输出到字节数组
byte [] barcodeInBytes = barcode.drawBarcodeAsBytes();

// 生成图形对象的条形码
图形图形= ...;
barcode.drawBarcode(graphics);

// 生成条形码并输出到HttpResponse对象
HttpResponse响应= ...;
barcode.drawBarcode(response);

// 生成条形码并输出到Stream对象
Stream stream = ...;
barcode.drawBarcode(stream);





链接:http://www.barcodelib.com/net_barcode/barcode_symbologies/qrcode.html [ ^ ]


请参阅以下文章,其中讨论了如何在ASP中显示QR码。 NET。





http: //www.hanselman.com/blog/HowToDisplayAQRCodeInASPNETAndWPF.aspx [ ^ ]

can any experts help?

protected void bn_create_Click(object sender, EventArgs e)
        {
            string url = tb_content.Text;
            QRCodeEncoder enc = new QRCodeEncoder();
            Bitmap qrcode = enc.Encode(url);
            
       }





I could make this work with windows form, but not web form. because there is no picture box on web, can anyone help me finish this codes? im using the messaging tool kit.

if u have any other ideas/help it will save my life pls...

解决方案

Please take a look this video. This would be useful to you.


Check this code snippet..
It may help you.

BarcodeLib.Barcode.QRCode barcode = new BarcodeLib.Barcode.QRCode();
     barcode.Data = "123456789012";

     barcode.ModuleSize = 3;
     barcode.LeftMargin = 0;
     barcode.RightMargin = 0;
     barcode.TopMargin = 0;
     barcode.BottomMargin = 0;

     barcode.Encoding = BarcodeLib.Barcode.QRCodeEncoding.Auto;
     barcode.Version = BarcodeLib.Barcode.QRCodeVersion.V1;
     barcode.ECL = BarcodeLib.Barcode.QRCodeErrorCorrectionLevel.L;
     barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

     // more barcode settings here

     // save barcode image into your system
     barcode.drawBarcode("c://barcode.png");
    
     // generate barcode & output to byte array
     byte[] barcodeInBytes = barcode.drawBarcodeAsBytes();
    
     // generate barcode to Graphics object
     Graphics graphics = ...;
     barcode.drawBarcode(graphics);
    
     // generate barcode and output to HttpResponse object
     HttpResponse response = ...;
     barcode.drawBarcode(response);
    
     // generate barcode and output to Stream object
     Stream stream = ...;
     barcode.drawBarcode(stream);



Link : http://www.barcodelib.com/net_barcode/barcode_symbologies/qrcode.html[^]


Please refer below article which talks about how to display a QR code in ASP.NET .


http://www.hanselman.com/blog/HowToDisplayAQRCodeInASPNETAndWPF.aspx[^]


这篇关于使用asp.net C#生成qr代码(Web表单)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆