RadCaptcha for ASP.NET AJAX

RadControls for ASP.NET AJAX

Getting Started

The following tutorial demonstrates using RadCaptcha to validate page submission. The walk-through will also show how to display the Error Message in a ValidationSummary.

  1. In the default page of a new ASP.NET AJAX-enabled Web Application add a RadCaptcha control, a Button control that causes post back on a click and a ValidationSummary control.

     
    Rad Captcha

  2. Open the RadCaptcha Smart Tag and select the Enable RadCaptcha httpHandler link. Click OK to close the confirmation dialog for the RadCaptcha handler.

     
    radcaptcha-smart-tag

    The httpHandler can be also enabled by placing the following lines in the web.config file:

    Copyweb.config
    <httphandlers>
        <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" /> 
    </httphandlers>
    
    
    <handlers>
        <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" /> 
    </handlers>
  3. In the Properties Window for the RadCaptcha control set the following properties:

    1. ErrorMessage = You have entered an invalid code.

    2. ValidationGroup = SubmitGroup

  4. In the Properties Window for the ValidationSummary control set the ValidationGroup property to the same value as in RadCaptcha (ValidationGroup = SubmitGroup). Do the same for the Button control.

  5. Press F5 to run the Application. RadCaptcha validates the input on a post back.

    Rad Captcha In Browser

RadCaptcha properties

 

Property

Description

Common

ErrorMessage

The error message text generated when the condition being validated fails.

ProtectionMode

Gets or sets which strategies are/to be used for Spam Protection. The available modes are:

  • Captcha

  • InvisibleTextBox

  • MinimumTimeout

CaptchaMaxTimeout

Gets or sets the maximum number of minutes CAPTCHA will be cached and valid.

CaptchaTextBoxLabel

Gets or sets the label which explains that the user needs to input the CAPTCHA text box.

ForeColor

Gets or sets the fore color of the error message.

Display

Gets or sets display behavior of error message. The available modes are:

  • None (Validator content never displayed inline)

  • Static (Validator content physically part of the page layout)

  • Dynamic (Validator content dynamically added to the page when validation fails)

ValidatedTextBoxID

Gets or sets the ID of the textbox to be validated, when only the RadCaptcha image is rendered on the page. (To render only the CaptchaImage and use Custom TextBox for user input, the CaptchaImage-RenderImageOnly property has to be set to true.)

ValidatedTextBox

Read-only. Gets the TextBox that is being validated by the RadCaptcha

IgnoreCase

Gets or sets a bool value indicating whether the RadCaptcha should ignore the case of the letters or not. By default it is false – the RadCaptcha does not make a difference between upper and lower case letters.

EnableRefreshImage

Gets or sets a bool value indicating whether or not the RadCaptchaImage can be refreshed. When set to true a LinkButton is rendered on the page that, when clicked, generates new image. The 'rcRefreshImage' CSS class is used for applying custom skinning to the LinkButton.

CaptchaLinkButtonText

Gets or sets the text of the LinkButton that generates a new CaptchaImage.

<CaptchaImage> Specific

AudioFilesPath

Gets or sets the path to the directory where the audio (.wav) files are located. The default path is ~/App_Data/RadCaptcha where tilde (~) represents the root of the web application.

EnableCaptchaAudio

Gets or sets the bool value indicating whether the CaptchaAudio will be enabled. When set to true a LinkButton is rendered that, when clicked, retrieves the audio code. Use the '.rcCaptchaAudioLink' selector to apply custom skinning to the LinkButton.

UseAudioFiles

Gets or sets a bool value indicating whether the audio code will be generated by concatenation of the audio files from a given folder.

FontWarp

Amount of random font warping to apply to rendered text:

  • None

  • Low

  • Medium

  • High

  • Extreme

BackgroundNoise

Amount of background noise to add to rendered image

LineNoise

Amount of curved line noise to add to rendered image

FontFamily

Sets the font used in the CAPTCHA image. This is the default list of fonts if none is provided:

  • Arial

  • Arial Black

  • Comic Sans MS

  • Courier New

  • Estrangelo Edessa

  • Franklin Gothic Medium

  • Georgia

  • Lucida Console

  • Lucida Sans Unicode

  • Mangal

  • Microsoft Sans Serif

  • Palatino Linotype

  • Sylfaen

  • Tahoma

  • Times New Roman

  • Trebuchet MS

  • Verdana

UseRandomFont

Gets or sets a bool value indicating whether a random font will be used to generate the CaptchaImage text. The font is selected randomly from the FontWhiteList.

TextChars

Sets the characters used in the CAPTCHA image:

  • LettersAndNumbers

  • Letters

  • Numbers

  • CustomCharSet

TextColor

Gets or sets the color of the CAPTCHA's text (System.Drawing.Color)

BackgroundColor

Gets or sets the background color of the CaptchaImage (System.Drawing.Color).

Height

Gets or sets the height of the CAPTCHA image.

Width

Gets or sets the width of the CAPTCHA image.

ImageAlternativeText

Gets or sets the ALT attribute of the IMG tag in the HTML

ImageCssClass

Gets or sets the CSS class of the CAPTCHA image

TextLength

Gets or sets the number of CaptchaChars used in the CAPTCHA text.

FontWhiteList

Gets or sets a semicolon-delimited list of valid fonts to use when no font is provided

ImageStorageLocation

Gets or sets the storage location for the CaptchaImage (see note below):

  • Cache

  • Session

RenderImageOnly

Gets or sets bool value that indicates whether the RadCaptcha image will only be rendered on the page (without the CaptchaTextBox and Label). When set to true only the image is rendered on the page. By setting the “ValidatedTextBoxID” property of the RadCaptcha, the user can choose a custom TextBox where the Captcha code will be entered and validated.

CharSet

Gets or sets a custom Character Set, from which the characters used to render the CaptchaImage, are randomly chosen. To use this property you must set the “CaptchaImage-TextChars” to CaptchaPossibleChars.CustomCharSet. The CharSet must contain at least 15 characters.

AutoBot Discovery specific Properties

InvisibleTextBoxLabel

Gets or sets the hidden textbox strategy label text.

MinTimeout

Gets or sets the minimum number of seconds form must be displayed before it is valid. If you're too fast, you must be a robot.

Note

By default the image is stored in the Cache. However, if more than one server is used to host the page (web-farm environment) the Session should be used, because if the Cache is used the image is stored locally on the server. When Session is used, the HttpHandler definition (in the .config file) of the RadCaptcha should be modified manually by setting the type of the HttpHandler has to be set to type="Telerik.Web.UI.WebResourceSession".