日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

根据内容来产生一个二维码

發(fā)布時間:2025/4/16 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 根据内容来产生一个二维码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

實(shí)現(xiàn)的功能以及效果如下:

?

樣式代碼:

?

.divtable {display: table;border-collapse: collapse;border-spacing: 0;margin-right: auto;margin-left: auto;width: 100%; }.divth, .divtr {display: table-row;vertical-align: middle;height: 20px;padding-left: 2px;padding-right: 2px; }.divth {background-color: #efebde;text-align: center; }.divtd {display: table-cell;border: 1px solid #c0c0c0; } Source Code

?

前端ASP.NET 代碼:

?

<div class="divtable" ><div class="divtr"><div class="divtd">內(nèi)容</div><div class="divtd" ><asp:TextBox ID="TextBoxQRCode" runat="server" Width="500" TextMode="MultiLine" Rows="20"></asp:TextBox></div></div><div class="divtr" style="line-height:40px;" ><div class="divtd">尺寸</div><div class="divtd">寬度:<asp:TextBox ID="TextBoxWidth" runat="server" Text="300"></asp:TextBox>高度:<asp:TextBox ID="TextBoxHeight" runat="server" Text="300"></asp:TextBox></div></div><div class="divtr" style="line-height:40px;" ><div class="divtd"></div><div class="divtd"><asp:Button ID="ButtonGenerate" runat="server" Text="生成" OnClick="ButtonGenerate_Click" /></div></div><div class="divtr" style="line-height:120px;" ><div class="divtd">二維碼</div><div class="divtd"><asp:PlaceHolder ID="PlaceHolderBarCode" runat="server" /></div></div></div> Source Code

?

把QRCoder.dll類庫引入Bin目錄中去:

然后在ASPX.CS引用命名空間:

using QRCoder; using System.IO; using System.Drawing;

?
OnClick事件:

?

protected void ButtonGenerate_Click(object sender, EventArgs e){string code = this.TextBoxQRCode.Text;QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);System.Web.UI.WebControls.Image imageBarCode = new System.Web.UI.WebControls.Image();imageBarCode.Height = string.IsNullOrEmpty(this.TextBoxHeight.Text.Trim()) ? 300 : Convert.ToInt32(this.TextBoxHeight.Text.Trim());imageBarCode.Width = string.IsNullOrEmpty(this.TextBoxWidth.Text.Trim()) ? 300 : Convert.ToInt32(this.TextBoxWidth.Text.Trim());using (Bitmap bitMap = qrCode.GetGraphic(20)){using (MemoryStream ms = new MemoryStream()){bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);byte[] byteImage = ms.ToArray();imageBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);}this.PlaceHolderBarCode.Controls.Add(imageBarCode);}} Source Code

?

轉(zhuǎn)載于:https://www.cnblogs.com/insus/p/9961782.html

總結(jié)

以上是生活随笔為你收集整理的根据内容来产生一个二维码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。