带字母的验证码.rar

时间:2011-11-03 04:31:09
【文件属性】:

文件名称:带字母的验证码.rar

文件大小:2KB

文件格式:RAR

更新时间:2011-11-03 04:31:09

验证码

using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace SCard { ///

/// 验证码生成器 /// public partial class ValidateCode : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { this.CreateCheckCodeImage(GenerateCheckCode()); } private string GenerateCheckCode() { int number; char code; string checkCode = String.Empty; System.Random random = new Random(); for(int i=0; i<5; i++) { number = random.Next(); //if(number % 2 == 0) code = (char)('0' + (char)(number % 10)); //else //code = (char)('a' + (char)(number % 26)); checkCode += code.ToString(); } //Response.Cookies.Add(new HttpCookie("CheckCode", checkCode)); Session["CheckCode"]=checkCode; return checkCode; }


【文件预览】:
有字母的验证码
----ValidateCode.aspx(87B)
----ValidateCode.aspx.cs(4KB)

网友评论