[c#]代码库
前台:
<div>
<asp:TextBox ID="txtCode" runat="server" Width="76px" class="kjia_3" Height="22px"></asp:TextBox>
<img id="imgVerify" style="width:100px; height:35px;" src="VerifyCode.aspx?'+Math.random()+'" alt="看不清?点击更换" onclick="this.src=this.src+'?'" />
<asp:Button ID="Button1" runat="server" Text="确定"
onclick="Button1_Click1" />
</div>
后台:按钮事件
protected void Button1_Click1(object sender, EventArgs e)
{
string code = "";
code = txtCode.Text.Trim();
if (String.Compare(Request.Cookies["CheckCode"].Value, code.ToString().Trim(), true) != 0)
{
Response.Write("<script>alert('验证码不正确');</script>");
return;
}
else
{
Response.Write("<script>alert('正确');</script>");
return;
}
}
[源代码打包下载]