Click here to Skip to main content
15,893,814 members
Articles / Web Development / ASP.NET

Free Captcha Control

Rate me:
Please Sign up or sign in to vote.
3.64/5 (10 votes)
9 Dec 2009CPOL2 min read 45.8K   3.4K   42  
Free Captcha Control
<%@ Page language="c#" AutoEventWireup="false" %>
<%@ Register Namespace="Captcha" Assembly="CaptchaControl" TagPrefix="cc" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script language="c#" runat="server">   
    void btnSubmit_Click(object sender, System.EventArgs e)
    {
        if (captcha.Validate(this.tbInput.Text))
        {
            //at this point we should redirect to a different page
            this.lblMsg.Text = "Code validated, image Deleted";
        }
        else
        {
            this.lblMsg.Text = "Validation failed, invalid code.";
        }       
    }

    void btnReset_Click(object sender, System.EventArgs e)
    {
      this.Response.Redirect("default.aspx");
    }
</script>

<html>	
	<body>
		<b>Captcha Control Test</b>	
		<form runat="server">
		<cc:CaptchaControl ID="captcha" runat="server"  CharCount="5" Width="200" CharSet="NumberAndLetters"/>			
			<p>
				<b>Enter the code shown above:</b><br/>
				<asp:TextBox id="tbInput" runat="server"></asp:TextBox>
				<asp:Button id="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"></asp:Button>
				<asp:Button id="btnReset" runat="server" Text="Reset" OnClick="btnReset_Click"></asp:Button><br/>
			</p>		
			<asp:Label id="lblMsg" runat="server"></asp:Label>
		</form>
	</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Oliver Wyman Groups
United States United States
Education: Masters in Applied mathematics

Certification:
MCP in Asp.net
MCP in SQL Server 2008 Implementation.

Working Experience In .Net since 2005

Comments and Discussions