Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Captcha / Custom Character Set




Characters to Use:
select





RadCaptcha Character Set (Enter at least 15 characters):

  • CaptchaImage Characters

    The RadCaptcha allows you to easily control the character set from which the CaptchaImage text is randomly generated. There are three predefined sets to choose from: LettersAndNumbers, Letters and Numbers. If you wish to specify your own character set, choose CustomCharSet for the CaptchaImage.TextChars property and set the desired character sequence to the CaptchaImage.CharSet property. Please note that for security reasons you need to provide at least 15 characters.

    Additionally you can tell the RadCaptcha to respect/ignore the letter case by setting a boolean value to the IgnoreCase property. By default the letter case is ignored (i.e. IgnoreCase="true").



Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Captcha.CharacterSet.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        <style type="text/css">
            .imageClass
            {
                padding-top: 10px;
                padding-bottom: 10px;
            }
            .textBox
            {
                display: block;
                margin-bottom: 10px;
            }
            .module1
            {
                background-color: #dff3ff;
                border: 1px solid #c6e1f2;
                padding: 15px 0 30px 10px;
                width: 350px;
            }
            .divConfig
            {
                background-color: #fff3c8;
                color: #000;
                border: 1px solid #ffe58a;
                float: left;
                width: 100%;
                margin-bottom: 25px;
            }
        </style>

        <script type="text/javascript">
            function pageLoad()
            {
                //Disable autoComplete
                $get("txtCharSet").setAttribute("autoComplete", "off");
            }
        </script>

    </head>
    <body class="BODY">
        <form id="Form2" method="post" runat="server" defaultbutton="btnValidate">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" ShowSkinChooser="false" />
        <telerik:RadScriptManager ID="ScriptManager" runat="server" />
        <telerik:RadFormDecorator ID="FormDecorator1" runat="server" DecoratedControls="All">
        </telerik:RadFormDecorator>
        <fieldset class="module1">
            <div style="float: left; padding-left: 20px">
                <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Page not valid. The code you entered is not valid."
                    ValidationGroup="Group" EnableRefreshImage="true" CaptchaTextBoxCssClass="textBox">
                    <CaptchaImage ImageCssClass="imageClass" BackgroundColor="#dff3ff" TextColor="Black" />
                </telerik:RadCaptcha>
                <div style="margin-top: 15px;">
                    <asp:Button ID="btnValidate" runat="server" Text="Verify Code" ValidationGroup="Group" />
                </div>
            </div>
        </fieldset>
        <br />
        <br />
        <div class="divConfig">
            <div style="float: left; padding: 0 0 15px 30px;">
                <br />
                Characters to Use:
                <telerik:RadComboBox ID="Characters1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Characters1_SelectedIndexChanged">
                    <Items>
                        <telerik:RadComboBoxItem Text="LettersAndNumbers" Selected="True" />
                        <telerik:RadComboBoxItem Text="Letters" />
                        <telerik:RadComboBoxItem Text="Numbers" />
                        <telerik:RadComboBoxItem Text="CustomCharSet" />
                    </Items>
                </telerik:RadComboBox>
                <br />
                <br />
    <asp:CheckBox ID="cbIgnoreCase" runat="server" Text="Ignore Case of the Letters"
    AutoPostBack="true" Checked="true" OnCheckedChanged="CheckBox_IgnoreCase" />

                <br />
                <br />
            </div>
            <div style="float: left; padding-left: 100px;">
                <br />
                <asp:Panel ID="Panel1" runat="server">
                    <span style="line-height: 250%;">RadCaptcha Character Set (Enter at least 15 characters):</span><br />
    <asp:TextBox ID="txtCharSet" runat="server" Text="abcdefghijkmnopqrstuvwxyz" Width="200px"
    Enabled="false" BorderStyle="Solid" CssClass="textBox"></asp:TextBox>

    <asp:Button ID="btnUpdateChanges" runat="server" Text="Set" OnClick="btnUpdateChanges_Click"
    Enabled="false" />

                </asp:Panel>
            </div>
        </div>
        <telerik:RadAjaxManager ID="ajaxManager" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Characters1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Characters1" />
                        <telerik:AjaxUpdatedControl ControlID="RadCaptcha1" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnUpdateChanges">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadCaptcha1" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="cbIgnoreCase">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadCaptcha1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <qsf:Footer runat="server" ID="Footer1" ShowCodeViewer="true" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451