1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Captcha.aspx.cs" Inherits="Captcha" %>
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5
<html xmlns="http://www.w3.org/1999/xhtml" >
6
<head runat="server">
7
<title>Untitled Page</title>
8
</head>
9
<body>
10
<form id="form1" runat="server">
11
<div>
12
13
</div>
14
</form>
15
</body>
16
</html>
17
===========================
18
Captcha.aspx.cs
19
20
using System;
21
using System.Data;
22
using System.Configuration;
23
using System.Collections;
24
using System.Web;
25
using System.Web.Security;
26
using System.Web.UI;
27
using System.Web.UI.WebControls;
28
using System.Web.UI.WebControls.WebParts;
29
using System.Web.UI.HtmlControls;
30
using System.Drawing.Drawing2D;
31
using System.Drawing;
32
using System.IO;
33
using System.Drawing.Imaging;
34
35
public partial class Captcha : System.Web.UI.Page
36
{
//这里可以改成你想设置的验证码字符集
66
//char[] s = 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' };
67
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//这里可以改成你想设置的验证码字符集
66
67
调用验证码的页面:register.aspx
1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5
<html xmlns="http://www.w3.org/1999/xhtml" >
6
<head id="Head1" runat="server">
7
<title>会员注册</title>
8
</head>
9
<body>
10
<form id="form1" runat="server">
11
<div class="middle" style="height: 1px" >
12
<div >
13
<asp:Label ID="UserName" runat="server" Text="用户名:" ></asp:Label>
14
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
15
</div>
16
<div >
17
<asp:Label ID="UserPsw" runat="server" Text="密码:" ></asp:Label>
18
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></div>
19
<div >
20
<asp:Label ID="Label2" runat="server" Text="确认密码:" ></asp:Label>
21
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></div>
22
<div >
23
<asp:Label ID="Question" runat="server" Text="找回密码问题:"></asp:Label>
24
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></div>
25
<div>
26
<asp:Label ID="Answer" runat="server" Text="找回密码答案:"></asp:Label>
27
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></div>
28
<div >
29
<asp:Label ID="Email" runat="server" Text="电子邮件:"></asp:Label>
30
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox></div>
31
<div >
32
<asp:Label ID="Label1" runat="server" Text="验证码:"></asp:Label>
33
<asp:TextBox ID="CheckCode" runat="server" Width="85px"></asp:TextBox>
34
<asp:Image id="Image1" runat="server" style="display:inline;" ImageUrl="Captcha.aspx"></asp:Image>
35
<asp:LinkButton ID="LinkButton1" runat="server">看不清楚,再换一张</asp:LinkButton></div>
36
<div>
37
<asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" /></div>
38
<div class="text">
39
<asp:Label ID="Message" runat="server" ></asp:Label></div>
40
</div>
41
</form>
42
</body>
43
44
</html>
45
46
=============================
47
Register.aspx.cs
48
49
using System;
50
using System.Data;
51
using System.Configuration;
52
using System.Collections;
53
using System.Web;
54
using System.Web.Security;
55
using System.Web.UI;
56
using System.Web.UI.WebControls;
57
using System.Web.UI.WebControls.WebParts;
58
using System.Web.UI.HtmlControls;
59
60
61
public partial class register : Page
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
源码下载:下载