step 1
download dll mscaptcha to my computer
step 2
Add references from mscaptcha.dll file
step 3
<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>
in aspx file
step 4
<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>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Label ID="lblMessage" runat="server" Text="lblMessage"></asp:Label>
input to the aspx file
step 5
protected void Button1_Click(object sender, EventArgs e)
{
try
{
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";
}
}
catch
{
Page_Load(sender,e);
}
}
input to cs file
ไม่มีความคิดเห็น:
แสดงความคิดเห็น