Friday, August 26, 2011

1. Captcha Control in asp.net



1. Captcha Control in Asp.Net


Add MSCaptcha.dll  (version: 1.0.2832.11804) in  Bin folder and add its reference

<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="mycap" %>
----------------------------------------------
  <httpHandlers>
    <remove verb="*" path="*.asmx"/>
   <add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
 </httpHandlers>

----------------------------------------------------
  <mycap:CaptchaControl ID="myCaptcha" Width="240" FontColor="#FFFFFF" runat="server"
    CaptchaBackgroundNoise="None" CaptchaLength="5" CaptchaHeight="35"
   CaptchaWidth="200"   LineColor="White" CaptchaMinTimeout="5" CaptchaMaxTimeout="245"
   BackColor="#922525"  BorderWidth="3" BorderColor="White" ToolTip="Enter the security code." />
                    <%-- BackColor="#B41610"--%>
                    <%-- BorderStyle="Dashed"--%>
                    <%-- CaptchaLineNoise="Extreme"--%>

-----------------------------------------------------

protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(txtSecurityCode.Text))
        {
            myCaptcha.ValidateCaptcha(txtSecurityCode.Text);

            if (myCaptcha.UserValidated)
            {
                lblerr.Text = "";
                Response.Redirect("Default2.aspx");
            }
            else
            {
                lblerr.Text = "Security Code Not Valid.!!";
            }
        }
        else
        {
            lblerr.Text = "Security Code Required.!!";
        }
    }
----------------------------------------------------------

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More