asp.net2.0生成验证码
来源:互联网 发布:网站源码下载 php 编辑:程序博客网 时间:2024/05/21 17:01
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.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing;
public partial class guestBook_ValitionNo : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
Random rd = new Random(); //创建随机数对象
int valationNo = 1000 + rd.Next(8999);//取得4位随机数
//建立位图对象
Bitmap newBitmap = new Bitmap(34, 16, PixelFormat.Format32bppArgb);
//根据上面创建的位图对象创建绘图面
Graphics g = Graphics.FromImage(newBitmap);
//以指定的颜色填充矩形区
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, 34, 16));
//创建字体对象
Font textFont = new Font("Times New Roman", 10);
//创建RectangleF结构指定一个区域
RectangleF rectangle = new RectangleF(6, 0, 34, 16);
//使用指定的颜色填充上面RectangleF结构指定的矩形区域
g.FillRectangle(new SolidBrush(Color.BurlyWood), rectangle);
//在上面填充的矩形区域中填充上面生成的随机数
g.DrawString(valationNo.ToString(), textFont, new SolidBrush(Color.Blue), rectangle);
//把创建的位图保存到指定的路径
newBitmap.Save(Server.MapPath("images") + /VaImg.gif, ImageFormat.Gif);
newBitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
}
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.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing;
public partial class guestBook_ValitionNo : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
Random rd = new Random(); //创建随机数对象
int valationNo = 1000 + rd.Next(8999);//取得4位随机数
//建立位图对象
Bitmap newBitmap = new Bitmap(34, 16, PixelFormat.Format32bppArgb);
//根据上面创建的位图对象创建绘图面
Graphics g = Graphics.FromImage(newBitmap);
//以指定的颜色填充矩形区
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, 34, 16));
//创建字体对象
Font textFont = new Font("Times New Roman", 10);
//创建RectangleF结构指定一个区域
RectangleF rectangle = new RectangleF(6, 0, 34, 16);
//使用指定的颜色填充上面RectangleF结构指定的矩形区域
g.FillRectangle(new SolidBrush(Color.BurlyWood), rectangle);
//在上面填充的矩形区域中填充上面生成的随机数
g.DrawString(valationNo.ToString(), textFont, new SolidBrush(Color.Blue), rectangle);
//把创建的位图保存到指定的路径
newBitmap.Save(Server.MapPath("images") + /VaImg.gif, ImageFormat.Gif);
newBitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
}
- asp.net2.0生成验证码
- asp.net2.0生成验证码,并显示验证码
- asp.net2.0生成验证码,并显示验证码
- 图形验证码页面Asp.Net2.0
- asp.net2.0生成一个复杂的验证码,背景随机,字体随机,中英文数字随机
- asp.net2.0生成一个复杂的验证码,背景随机,字体随机,中英文数字随机
- ASP.net2.0表单验证
- asp.net2.0验证控件
- ASP.NET2.0 生成缩略图
- 一个图形验证码页面(Asp.Net2.0通过)
- 一个图形验证码页面(Asp.Net2.0通过)
- asp.net2.0的验证控件介绍
- asp.net2.0密码强度验证
- asp.net2.0 验证控件全部失效
- asp.net2.0密码强度验证
- asp.net2.0密码强度验证
- asp.net2.0密码强度验证
- asp.net2.0安全性(验证与授权)
- asp.net2.0 发布网站选项说明
- 高效程序员应该养成的七个习惯
- 引用重解析和struct继承
- 数据库索引应用
- asp.net2.0 收发邮件
- asp.net2.0生成验证码
- PetShop数据访问层之消息处理(《解剖PetShop》系列之三)
- .NET Socket开发之同步Socket实现两例
- VS2.0 对GridView的一些汇总操作 (二)
- IE Web Control 的 TreeView 的 treeview.htc 报告 tagName 为空或不是对象的问题
- VS2.0 对GridView的一些汇总操作 (二)
- sscanf函数的用法
- 谈C++中的自加
- 从Gridview中获取全部数据