MS Captcha with refresh button in asp.net
MS Captcha with refresh button in asp.net
Step 1: Design web from .aspx Page
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<cc1:CaptchaControl ID="Captcha1"
runat="server"
CaptchaBackgroundNoise="Low"
CaptchaLength="6"
CaptchaHeight="80"
CaptchaWidth="350"
CaptchaLineNoise="None"
CaptchaMinTimeout="5"
CaptchaMaxTimeout="240"
FontColor="CadetBlue"
/>
<asp:LinkButton ID="lnkrefresh"
runat="server"
OnClick="_Click"
Text="Refresh"
CausesValidation="false">
</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:TextBox ID="txtCaptcha"
runat="server"
Width="350px"></asp:TextBox>
<br />
<asp:Button ID="btn" runat="server"
Text="Check"
OnClick="btn_Click"
BackColor="YellowGreen"
/>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ErrorMessage="*Required"
ControlToValidate="txtCaptcha"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="lblmsg" runat="server"
Font-Names="Arial"
Text=""></asp:Label>
</form>
Step 2: Logic on .Cs page.
protected void btn_Click(object sender, EventArgs
e)
{
Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());
if (Captcha1.UserValidated)
{
lblmsg.ForeColor = System.Drawing.Color.Green;
lblmsg.Text = "Sucess";
}
else
{
lblmsg.ForeColor = System.Drawing.Color.Red;
lblmsg.Text = "Fail";
}
}
protected void
_Click(object sender, EventArgs
e)
{ }
Comments
Post a Comment