asp.net验证码制作实例代码
效果图
Default.aspx页面的内容
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Verify._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="viewImg.aspx" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
Default.aspx.cs页面的内容
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Verify
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string text = this.TextBox1.Text.ToString();//获得用户输入的验证码
 
相关文档:
asp.net 发布网站时有三个选项:
1、允许更新此预编译站点:asp.net web 页面通常包含两个页面,一个即 .aspx 页,还有一个 .aspx.cs 文件,后一个文件是基本委托的事件响应文件代码;此处允许更新此预编译站点的意思就是:.aspx 页可根据需要进行一定的更新,而 .aspx.cs 编译成的 .dll 保持不变;另外,如果发布网站时只 ......
例一:
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{ }
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs e)
{ }
void ......
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs ......
+++ 修改WebConfig文件:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="connStr" value="Data Source=ora11g;uid=scott;pwd=tiger;unicode=true"/>
</appSettings>
<connectionStrings>
<ad ......