All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.Net中MD5和SHA1加密的几种方法_[Asp.Net教程]
关于C#中timer类,在C#里关于定时器类就有3个_[Asp.Net教程]
ASP.NET如何保留两位小数点_[Asp.Net教程]
asp.net得到全部已选中的RedioButton的值_[Asp.Net教程]
SQL之更多的子查询_[SQL,Server教程]
Asp.net,水晶报表之打印和导出格式_[Asp.Net教程]
C#中的多媒体技术:文字处理
为什么PHP令人不爽(对于大型系统)_[PHP教程]
c#编程中学习数据结构的必要性
PHP实例:PHP批量生成缩略图_[PHP教程]
Reading number is top 10 pictures
Ashlynn Brooke show proud chest measurement3
男人,就要活出棱角
Discharge accidentally Actresses by the breast4
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line2
NeedWallpaper9
Desktop Wallpapers1
抗日又出雷剧情
为什么别人说你是疯子
赵惟依写真2
Terrorist smile the largest human history an explosion1
Download software ranking
Tram sex maniac 2 (H) rar bag1
Ashlynn Video2
WebService在.NET中的实战应用教学视频 → 第1集
Tram sex maniac 2 (H) rar bag9
Boxer Classic video1
少妇苏霞全本
Tram sex maniac 2 (H) rar bag7
linux安装大全
Photoshop 8.0图象编辑软件
Sora aoi‘s film--Lust fan wall
delv published in(发表于) 2014/1/23 3:12:16 Edit(编辑)
Asp.net无刷新中文验证码调试成功,特分享给大家_[Asp.Net教程]

Asp.net无刷新中文验证码调试成功,特分享给大家_[Asp.Net教程]

Asp.net无刷新中文验证码调试成功,特分享给大家_[Asp.Net教程]

以前在网上找到了很多关于中文验证码的文章(园子里也有,大家自己去找吧),但是都没有调测成功,总出现
The target '__Page' for the callback could not be found or did not implement ICallbackEventHandler不能ICallbackEventHandler回掉的错误,我进行了一下修正并整理,现在可以实现了中文验证码无刷新的操作,现特把全部源码分享给大家

核心源码


1 public partial class Image : System.Web.UI.Page
2 {
3 protected void Page_Load(object sender, EventArgs e)
4 {
5 CreateCheckCodeImage(GenCode(4));
6 }
7 /**//**//**////


8 /// '产生随机字符串
9 ///

10 /// 随机出几个字符
11 /// 随机出的字符串
12 private string GenCode(int num)
13 {
14 string str = "的一是在不了有和人这中大为上个国我以要他时来用们...";
15 char[] chastr = str.ToCharArray();
16
17 string code = "";
18 Random rd = new Random();
19 int i;
20 for (i = 0; i < num; i++)
21 {
22 //code += source[rd.Next(0, source.Length)];
23 code += str.Substring(rd.Next(0, str.Length), 1);
24 }
25 return code;
26
27 }
28
29 /**//**//**////
30 /// 生成图片(增加背景噪音线、前景噪音点)
31 ///

32 /// 随机出字符串
33 private void CreateCheckCodeImage(string checkCode)
34 {
35 if (checkCode.Trim() == "" || checkCode == null)
36 return;
37 Session["Code"] = checkCode; //将字符串保存到Session中,以便需要时进行验证
38 System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)(checkCode.Length * 21.5), 22);
39 Graphics g = Graphics.FromImage(image);
40 try
41 {
42 //生成随机生成器
43 Random random = new Random();
44
45 //清空图片背景色
46 g.Clear(Color.White);
47
48 // 画图片的背景噪音线
49 int i;
50 for (i = 0; i < 25; i++)
51 {
52 int x1 = random.Next(image.Width);
53 int x2 = random.Next(image.Width);
54 int y1 = random.Next(image.Height);
55 int y2 = random.Next(image.Height);
56 g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
57 }
58
59 Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold));
60 System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2F, true);
61 g.DrawString(checkCode, font, brush, 2, 2);
62
63 //画图片的前景噪音点
64 g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
65 System.IO.MemoryStream ms = new System.IO.MemoryStream();
66 image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
67 Response.ClearContent();
68 Response.ContentType = "image/Gif";
69 Response.BinaryWrite(ms.ToArray());
70
71 }
72 catch
73 {
74 g.Dispose();
75 image.Dispose();
76 }
77
78 }


希望该源码只是一个抛砖引玉的作用,你可以进行修改,比如说改中文字库,字体背景噪音等等
默认帐号密码均为51aspx,这里用户登录只是一个验证的例子,没有其他功能


作者51aspx
完整源码下载地址http://www.51aspx.com/CV/ZhongWenYanZhengMa







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.