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:DropDownList ID="compactType" runat="server" AutoCallBack="True" Width="153px"> </asp:DropDownList>
<?xml version="1.0" encoding="utf-8" ?>
<roots>
<root>
<id>1</id>
<Culture> ......
//思路:将其IP存入数据库的时候,以数字的形式存入.即可比较大小.
//比如:192.168.1.1 凡是后面位数不满3位的都以0填充.....那么存入形式为:192168001001
//因为:1只有一位...所以加00这样数据库中全部的都为12位的数字,即可比较.
public string getip(string ip)
{
......