您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->唐唐企业管理网站源码>>Manager/CheckImage.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:唐唐企业管理网站源码
当前文件:文件类型 TangCompany/Manager/CheckImage.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Drawing; 12using System.Text; 13using System.Drawing.Drawing2D; 14using System.Drawing.Imaging; 15 16public partial class Manager_CheckImage : System.Web.UI.Page 17{ 18 protected void Page_Load(object sender, EventArgs e) 19 { 20 CheckImage(GetCode(5)); 21 } 22 //返回验证码的位数 23 protected string GetCode(int i) { 24 25 Random ran = new Random(); 26 string strCode = string.Empty; 27 string[] str ={ "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", "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" }; 28 for (int j = 0; j < i; j++) { 29 30 strCode += str[ran.Next(str.Length)]; 31 32 } 33 Session["CheckCode"] = strCode; 34 return strCode; 35 36 } 37 protected void CheckImage(string nCode) { 38 39 Random ran=new Random(); 40 Bitmap img = new Bitmap(70, 24); 41 Graphics g = Graphics.FromImage(img); 42 g.Clear(System.Drawing.Color.White); 43 for (int i = 0; i < 30; i++) { 44 45 g.DrawLine(Pens.Gainsboro, new Point(ran.Next(img.Width), ran.Next(img.Height)), new Point(ran.Next(img.Height),ran.Next(img.Width))); 46 47 } 48 g.DrawRectangle(Pens.Green, new Rectangle(0, 0, 69, 23)); 49 Font font = new Font("Arail", 12, FontStyle.Bold); 50 g.DrawString(nCode, font, Brushes.Black, new Point(5, 4)); 51 System.IO.MemoryStream ms = new System.IO.MemoryStream(); 52 img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); 53 Response.ClearContent(); 54 Response.ContentType = "Image/Gif"; 55 Response.BinaryWrite(ms.ToArray()); 56 57 } 58} 59
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:唐唐企业管理网站源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号