asp.net生成条形码
aspx
页面只要有一个textbox,一个button和一个Image控件就可以了
下面是cs文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Cobainsoft.Windows.Forms;
using System.Drawing;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.IO;
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Image1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
//得到图片路径
string path = Server.MapPath(".") + "\\dd.gif";
string strtxm = TextBox1.Text.ToUpper();
FileStream filestr = new FileStream(path, FileMode.Create);
Cobainsoft.Windows.Forms.BarcodeControl control = new BarcodeControl();//实例化
control.BarcodeType = BarcodeType.CODE128A;//启用的编码
control.Data = strtxm;//生成编码的字符串
control.StretchText = false;
control.CopyRight = "";//显示标题
filestr.Close();//关闭文件
control.SaveImage(ImageFormat.Gif, 1, 70, true, false, null, path);
Image1.Visible = true;
Image1.ImageUrl = "dd.gif";
}
}