验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
2008-01-17 13:05
531 查看
[align=center]验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#[/align]
网上有很多关于验证码做法的资料,但是真正做得完整的却非常少,所以昨天晚上参考了作者:CSDN 上kwklover 的在ASP.NET下实现数字和字符相混合的验证码 (混合,完整,遗憾的是vb.net,说到这里我想我得感谢stone(QQ9337874),因为我在把VB译成C#的过程中几番出错,最终这段翻译由他完成)!!
随机汉字参考了http://navicy.cnblogs.com/archive/2005/05/08/150756.html这篇文章的,
而最终的纯数字以及GDI+绘图则是从□☆近三十☆(QQ19302038)传给我的一个OA案例里面分离出来的!
所以完整的说,这里面几乎都是别人做好了的,我只是整理出来了!
完整的下载地址是 http://files.cnblogs.com/thcjp/gdi.rar
下面把代码的重点部分贴出来,如果看源文件有什么不明白可以问偶 QQ110535808
效果如图(我确实懒了点,按纽的名字都没有改,哈哈)
需要说明的是,因为提交对比后,页面是重新刷新了,所以文本框里面看见的和后面图片显示不一样,这个不需要太多说明吧!!
混合模式刷新出现约界错误 已经被 stone(QQ9337874) 修正!!
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.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing;
using System.Text;
public partial class png : System.Web.UI.Page
private String GetRandomint()
public static String RndNum(int VcodeNum)
public static object[] CreateRegionCode(int strlength)
private string stxt()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Image ID="Image1" runat="server" ImageUrl="png.aspx" /><br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="3">默认</asp:ListItem>
<asp:ListItem Value="1">文字</asp:ListItem>
<asp:ListItem Value="2">数字</asp:ListItem>
<asp:ListItem Value="3">混合</asp:ListItem>
</asp:DropDownList></div>
</form>
</body>
</html>
CS代码
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
protected void Button2_Click(object sender, EventArgs e)
{
if (TextBox1.Text == Session["gif"].ToString())
Response.Write("OK,正确");
else
Response.Write("验证码不符合");
}
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=951869
网上有很多关于验证码做法的资料,但是真正做得完整的却非常少,所以昨天晚上参考了作者:CSDN 上kwklover 的在ASP.NET下实现数字和字符相混合的验证码 (混合,完整,遗憾的是vb.net,说到这里我想我得感谢stone(QQ9337874),因为我在把VB译成C#的过程中几番出错,最终这段翻译由他完成)!!
随机汉字参考了http://navicy.cnblogs.com/archive/2005/05/08/150756.html这篇文章的,
而最终的纯数字以及GDI+绘图则是从□☆近三十☆(QQ19302038)传给我的一个OA案例里面分离出来的!
所以完整的说,这里面几乎都是别人做好了的,我只是整理出来了!
完整的下载地址是 http://files.cnblogs.com/thcjp/gdi.rar
下面把代码的重点部分贴出来,如果看源文件有什么不明白可以问偶 QQ110535808
效果如图(我确实懒了点,按纽的名字都没有改,哈哈)
需要说明的是,因为提交对比后,页面是重新刷新了,所以文本框里面看见的和后面图片显示不一样,这个不需要太多说明吧!!
混合模式刷新出现约界错误 已经被 stone(QQ9337874) 修正!!
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.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing;
using System.Text;
public partial class png : System.Web.UI.Page
private String GetRandomint()
public static String RndNum(int VcodeNum)
public static object[] CreateRegionCode(int strlength)
private string stxt()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Image ID="Image1" runat="server" ImageUrl="png.aspx" /><br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="3">默认</asp:ListItem>
<asp:ListItem Value="1">文字</asp:ListItem>
<asp:ListItem Value="2">数字</asp:ListItem>
<asp:ListItem Value="3">混合</asp:ListItem>
</asp:DropDownList></div>
</form>
</body>
</html>
CS代码
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
protected void Button2_Click(object sender, EventArgs e)
{
if (TextBox1.Text == Session["gif"].ToString())
Response.Write("OK,正确");
else
Response.Write("验证码不符合");
}
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=951869
相关文章推荐
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 转:验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合] C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母\数字\汉字混合]C#
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]
- 验证码的三种做法[纯数字][纯汉字][字母/数字/汉字混合]
- 如何生成汉字验证码或字母数字混合验证码
- C# 生成四位数字字母混合验证码
- 字母验证码 数字,字母数字混合也可
- C# 正则表达式验证代码(字母、数字、Email、网址、电话号码、汉字、身份证号码)