易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net 验证码

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.Drawing2D;
using System.Drawing.Imaging;
using System.Text;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
static readonly char[] codeList = new char[]{'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'};
string sessionKey = "ValidateCode";//保存在Session中所用的KEY
int codeLength = 5; //验证码字符长度
int width = 80; //验证码图片宽度
int height = 20; //验证码图片高度
int fontSize = 14; //验证码字体大小
protected void Page_Load(object sender, EventArgs e)
{
//获取验证码字符串
string strCode = GetValidateCode();
//将验证码字符串保存到Session中
Session[sessionKey] = strCode;
//实例化图片
using (Bitmap img = new Bitmap(width, height))
{
//获取画板
using (Graphics g = Graphics.fromImage(img))
{
g.Clear(Color.White);
Random random = new Random();
//画图片的背景噪音线
for (int i = 0; i < 15; i++)
{
int x1 = random.Next(width);
int x2 = random.Next(width);
int y1 = random.Next(height);
int y2 = random.Next(height);
g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
}


相关文档:

ASP.NET单值和列表控件的数据绑定

一、(单值绑定)在页面的后台代码中定义公有变量,如下:
 public string gongYou = "声明的公有成员";
 ①然后在页面的源中调用,如下:
<asp:Label ID="lblMgs" runat="server" Text="<%#gongYou >"></asp:Label>
  ②当然最后要记得绑定数据:
 protected void Page_Load(object ......

iis6解决运行asp.net mvc

配置iis6解决运行asp.net mvc项目“无法找到该页”的错误
在iis6运行asp.net mvc 项目时,如果出现“无法找到该页”的提示,即404错误,那么有可能是iis没有设置好,按下面操作可以解决:
打开iis管理器,右击相应的网站节点,选择“属性”快捷菜单,弹出属性对话框,选择“主目录&rd ......

ASP.NET页面生命周期


有很多理由去解释理解ASP.NET页面生命周期是非常重要的,主要是要去理解什么地方放置什么特定的方法,什么时候我们应该设置什么相关的属性。如果去开发自定义的服务器控件,理解生命周期对纠正控件初始化时候的错误,以及使用view-state和后台代码设置属性是非常有用的。(控件事件只与ASP.NET页面相关)
  &n ......

asp.net 4种事务


<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......

谨慎Asp.net中static变量的用法

谨慎Asp.net中static变量的用法
.Net技术 2007-01-30 22:17:37 阅读925 评论11 字号:大中小
谨慎Asp.net中static变量的用法
    在.Net平台下进行CS软件开发时,我们经常遇到以后还要用到某些变量上次修改后的值,为了简单起见,很多人都习惯用static来定义这些变量,我也是。这样非常方便,下一次调用某个 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号