MSCaptcha in Asp.net

MSCaptcha in Asp.net


Step 1: Design web form .aspx page

<cc1:CaptchaControl ID="Captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="6"
            CaptchaHeight="80" CaptchaWidth="350" CaptchaLineNoise="None" CaptchaMinTimeout="5"
            CaptchaMaxTimeout="240" FontColor="CadetBlue" />
    </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>

 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";
        }
    }

It will look like



Comments

Popular posts from this blog

Create and save QR code in asp.net with C#

Change text of RadGrid Header Dynamically

Telerik Radwindow Open on Button Click