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

Reading number is top 10 articles
JS获取网页中HTML元素的几种方法分析_[Html教程]
c#中邮件收发处理(POP3,IMAP,SMTP)_[Asp.Net教程]
做完一个小网站的一点经验总结(2):,asp.net+access程序运行环境的配置_[Asp.Net教程]
在使用ASP.NET网站管理工具出现“遇到错误。请返回上一页并重试。”的解决办法!_[Asp.Net教程]
常用技巧:用PHP控制您的浏览器cache_php资料_编程技术
XSL教程:了解基础知识关于XSL_[XML教程]
asp.net2.0指定和禁用主题
为项目添加新类
asp.net把输入文字转化成图片_[Asp.Net教程]
5种易犯的PHP数据库错误_[PHP教程]
Reading number is top 10 pictures
Sell the barbecue as says father du breul4
Plump, too plump!2
这还能睡得着?
The mother was a stay-at-home children too tired took three baby suicide
全球清廉国家排行
恶搞漫画2
青春清纯美女大集合2
美奂绝伦的风景
Take you to walk into the most true north Korea rural1
So beauty, will let you spray blood10
Download software ranking
asp.net技术内幕
Ashlynn Video3
Tram sex maniac 2 (H) rar bag2
Twenty piece of palm leaf
网络管理员第三版
Boxer vs Yellow3
jBuilder2006
Unix video tutorial14
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
Call Of Duty2
delv published in(发表于) 2014/1/6 8:49:08 Edit(编辑)
asp.net,生成图片验证码_[Asp.Net教程]

asp.net,生成图片验证码_[Asp.Net教程]

asp.net 生成图片验证码_[Asp.Net教程]

identifyingcode.aspx里没有内容略。
identifyingcode.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 System.Drawing;
using System.Drawing.Imaging;
using System.IO;
public partial class identifyingcode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string tmp = RndNum(4);
HttpCookie a = new HttpCookie("ImageV", tmp);
Response.Cookies.Add(a);
this.ValidateCode(tmp);


}
private void ValidateCode(string VNum)
{
Bitmap Img = null;
Graphics g = null;
MemoryStream ms = null;


int gheight = VNum.Length * 12;
Img = new Bitmap(gheight, 25);
g = Graphics.FromImage(Img);
//背景颜色
g.Clear(Color.LightSteelBlue);
//文字字体
Font f = new Font("Arial Black", 10);
//文字颜色
SolidBrush s = new SolidBrush(Color.RoyalBlue);
g.DrawString(VNum, f, s, 3, 3);
ms = new MemoryStream();
Img.Save(ms, ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "images/Jpeg";
Response.BinaryWrite(ms.ToArray());
g.Dispose();
Img.Dispose();
Response.End();
}


private string RndNum(int VcodeNum)
{
string Vchar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p" +
",q,r,s,t,u,v,w,x,y,z";
string[] VcArray = Vchar.Split(new Char[] { ',' });
string VNum = "";
int temp = -1;


Random rand = new Random();


for (int i = 1; i < VcodeNum + 1; i++)
{
if (temp != -1)
{
rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
}


int t = rand.Next(35);
if (temp != -1 && temp == t)
{
return RndNum(VcodeNum);
}
temp = t;
VNum += VcArray[t];
}
return VNum;
}


}

使用方法:
在需要它的页面html里添加


HttpCookieCollection cookies = Request.Cookies;
string tmp = cookies["ImageV"].Value;
然后比tmp与获取的较验证码文本框中的值是否相同


来源:网络







添加到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.