Here we discuss about how to create Captcha using DLL
.aspx File
<%@ Register Assembly=”MSCaptcha” Namespace=”MSCaptcha” TagPrefix=”cc1″ %>
<form id=”form1″ runat=”server”>
<div>
<cc1:CaptchaControl ID=”Captcha1″ runat=”server”
CaptchaBackgroundNoise=”Low” CaptchaLength=”5″
CaptchaHeight=”60″ CaptchaWidth=”200″
CaptchaLineNoise=”None” CaptchaMinTimeout=”5″
CaptchaMaxTimeout=”240″ FontColor = “#529E00″ />
</div>
<asp:TextBox ID=”txtCaptcha” runat=”server”></asp:TextBox>
<br />
<asp:Button ID=”btnVerify” runat=”server” Text=”Verify” OnClick=”btnVerify_Click” />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=”*Required” ControlToValidate = “txtCaptcha”></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID=”lblMessage” runat=”server” Font-Names = “Arial” Text=””></asp:Label>
</form>
CodeBehind File
protected void btnVerify_Click(object sender, EventArgs e)
{
Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());
if (Captcha1.UserValidated)
{
lblMessage.ForeColor = System.Drawing.Color.Green;
lblMessage.Text = “Valid”;
}
else
{
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = “InValid”;
}
}
Note : Download .dll here