[转]ASP.net(c#)生成条形码
本文转自:http://www.systron.com.cn/tiaoxingma/txm53.htm
using System;
using System.Data;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(bar_code("*ABC123*", 100, 2, 2));
}
public string bar_code(object str, int ch, int cw, int type_code)
{
//str:输入的字符串;ch:要显示条形码的高度;cw:要显示条形码的宽度;type_code:代码类型
string strTmp = str.ToString();
string code = strTmp;
// ToLower()将string转化成小写形式的副本,返回是使用指定区域的性的大小写规则。
strTmp = strTmp.ToLower();
int height = ch;
int width = cw;
//将传入的参数进行转化。
strTmp = strTmp.Replace("0", "_|_|__||_||_|"); ;
strTmp = strTmp.Replace("1", "_||_|__|_|_||");
strTmp = strTmp.Replace("2", "_|_||__|_|_||");
strTmp = strTmp.Replace("3", "_||_||__|_|_|");
strTmp = strTmp.Replace("4", "_|_|__||_|_||");
strTmp = strTmp.Replace("5", "_||_|__||_|_|");
strTmp = strTmp.Replace("7", "_|_|__|_||_||");
strTmp = strTmp.Replace("6", "_|_||__||_|_|");
strTmp = strTmp.Replace("8", "_||_|__|_||_|");
strTmp = strTmp.Replace("9", "_|_||__|_||_|");
strTmp = strTmp.Replace("a", "_||_|_|__|_||");
strTmp = strTmp.Replace("b", "_|_||_|__|_||");
strTmp = strTmp.Replace("c", "_||_||_|__|_|");
strTmp = strTmp.Replace("d", "_|_|_||__|_||");
strTmp = strTmp.Replace("e", "_||_|_||__|_|");
strTmp = strTmp.Replace("f", "_|_||_||__|_|");
strTmp = strTmp.Replace("g", "_|_|_|__||_||");
strTmp = strTmp.Replace("h", "_||_|_|__||_|");
strTmp = strTmp.Replace("i", "_|_||_|__||_|");
strTmp = strTmp.Replace("j", "_|_|_||__||_|");
strTmp = strTmp.Replace("k", "_||_|_|_|__||");
strTmp = strTmp.Replace("l", "_|_||_|_|__||");
strTmp = strTmp.Replace("m", "_||_||_|_|__|");
strTmp = strTmp.Replace("n", "_|_|_||_|__||");
strTmp = strTmp.Replace("o", "_||_|_||_|__|");
strTmp = strTmp.Replace("p", "_|_||_||_|__|");
strTmp = strTmp.Replace("r", "_||_|_|_||__|");
strTmp = strTmp.Replace("q", "_|_|_|_||__||");
strTmp = strTmp.Replace("s", "_|_||_|_||__|");
strTmp = strTmp.Replace("t", "_|_|_||_||__|");
strTmp = strTmp.Replace("u", "_||__|_|_|_||");
strTmp = strTmp.Replace("v", "_|__||_|_|_||");
strTmp = strTmp.Replace("w", "_||__||_|_|_|");
strTmp = strTmp.Replace("x", "_|__|_||_|_||");
strTmp = strTmp.Replace("y", "_||__|_||_|_|");
strTmp = strTmp.Replace("z", "_|__||_||_|_|");
strTmp = strTmp.Replace("-", "_|__|_|_||_||");
strTmp = strTmp.Replace("*", "_|__|_||_||_|");
strTmp = strTmp.Replace("/", "_|__|__|_|__|");
strTmp = strTmp.Replace("%", "_|_|__|__|__|");
strTmp = strTmp.Replace("+", "_|__|_|__|__|");
strTmp = strTmp.Replace(".", "_||__|_|_||_|");
strTmp = strTmp.Replace("_", "<span style='height:" + height + ";width:" + width + ";background:#FFFFFF;'></span>");
strTmp = strTmp.Replace("|", "<span style='height:" + height + ";width:" + width + ";background:#000000;'></span>");
if (type_code == 1)
{
return strTmp + "<BR>" + code;
}
else
{
return strTmp;
}
}
}
[转]ASP.net(c#)生成条形码相关推荐
- 使用html2canvas实现批量生成条形码
/*前台代码*/ 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gener ...
- C#利用ZXing.Net生成条形码,二维码和带Logo的二维码
本文是利用ZXing.Net在WinForm中生成条形码,二维码的小例子,仅供学习分享使用,如有不足之处,还请指正. 什么是ZXing.Net? ZXing是一个开放源码的,用Java实现的多种格式的 ...
- php+条形码在线怎么生成,PHP_php实现在线生成条形码示例分享(条形码生成器),复制代码 代码如下: n - phpStudy...
php实现在线生成条形码示例分享(条形码生成器) define('IN_CB',true); include('header.php'); $keys = array('0','1','2','3', ...
- Asp.net动态生成html页面
作者:网际浪子专栏(曾用名littlehb) http://blog.csdn.net/littlehb/ 适用于:Microsoft ASP.NET 摘要:asp.net动态生成html页面,适用 ...
- php tp5生成条形码,thinkphp5 + barcode 生成条形码
2.解压放到"E:phpstudyPHPTutorialWWWguahaovendor下",其中class文件是所有的类文件,生成条形码就是调用文件夹里的类,font文件是字体,i ...
- pHp封装成vue,vue.js生成条形码的方法
本文主要和大家分享vue.js生成条形码的方法,主要以代码的形式和大家分享,希望能帮助到大家. 1.下载插件npm install @xkeshi/vue-barcode //下载条形码插件 2.在m ...
- ASP.NET MVC 生成简单的 xml 权限结构
ASP.NET MVC 生成简单的 xml 权限结构 当我的一个项目到尾声时,发现系统很多模块权限有遗漏.部分模块权限遗漏是由于前期开发速度太快,开发人员未先给模块加权限而后再编写该模块功能代码.当我 ...
- ASP程序快速生成Excel文件
ASP程序快速生成Excel文件 在一个web项目中,要求将数据生成Excel文件保存到本地,最早使用的方法是直接使用Microsoft的Office Web组件,但是总体感觉是慢(微软的通病).然后 ...
- 动态asp网页批量生成静态html网页问题
<% '读取模板 set rs=server.createobject("adodb.recordset") rs.open ("select tradeinfo_ ...
最新文章
- ASP.NET MVC Routing、Areas、URLs
- PHP是弱类型语言,自动转换,强制转换
- python列表统计每个元素出现次数_python 统计list中各个元素出现的次数的几种方法...
- springboot mysql事物_SpringBoot事务详细简介
- 马尔科夫决策过程(MDP) : BlackJack问题(MC-ES)
- 功能1 -- 顶部导航栏和返回顶部效果
- MATLAB实验总结定积分,matlab实验报告--定积分的近似计算 -
- 非常简单Java web下Office转PDF功能实现 100%能用
- 杭电ACMSteps中Chapter One——Section 3中所有ac代码及解析
- 屏蔽烦人的网易云音乐评论区(附防颓小技巧)
- 【Angular】refresher刷新器
- 易语言调用大漠Ocr文字识别游戏角色坐标
- 使用rotate()来做一个3d贺卡
- 微软提出基于知识图谱的深度神经网络DKN用于新闻推荐
- Windos10使用手册
- 初识LTE(五):完整的SISO LTE 物理层实现
- 第七次c++上机实验
- Katago围棋学习记录(二)
- 领域知识库构建及信息检索系统
- sshd: Corrupted MAC on input
热门文章
- unity fixedupdate_Unity之滚球游戏(上)
- java如何无感知部署_干货!如何平稳用户无感知的完成系统重构升级
- 时间记录html,jquery水平、垂直时间线记录jQuery Timelinr
- 通过html备份数据库文件,备份网站文件和数据库
- java局部内部类_Java 局部内部类、匿名内部类详解
- python flask webapi_在将Python Flask webapi部署到azurep时遇到依赖性问题
- git rebase 修改提交信息
- setuptools setup()
- javascript Control flow(控制语句)
- Hadoop sqoop