New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Server Side Events

Enter the sum of the digits in the validation code
(enter 0 if there are no digits):

RadCaptcha provides the server-side CaptchaValidate event which is fired before the control is validated. This event allows you to execute server-side code on RadCaptcha validation, to cancel the default validation mechanism of the captcha control and to specify your own logic for validating the input code.

The CaptchaValidateEventArgs object of the CaptchaValidate event exposes the following properties:

  • CancelDefaultValidation—specifies whether the default validation of RadCaptcha will proceed after the event is fired.
  • IsValid—determines whether the RadCaptcha validation is successful. It should be used if CancelDefaultValidation is set to true.

This example demonstrates how to implement custom RadCaptcha validation:

  • The CancelDefaultValidation property of the event arguments object is set to true so that the default validation is not executed.
  • The IsValid property of the captcha control is set depending on the condition that should be met in order for the RadCaptcha to be validated.
  • In addition to this, the border of the captcha image is changed to notify whether the validation is successful.
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • Styles.css
<%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Captcha.ServerSideEvents.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadFormDecorator RenderMode="Lightweight" ID="FormDecorator1" runat="server" DecoratedControls="All" DecorationZoneID="zoneToDecorate">
    <div class="demo-containers">
    <div class="demo-container" id="zoneToDecorate">
        <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="Group" ErrorMessage="Page not valid. The code you entered is not valid."
            CaptchaTextBoxCssClass="textBox" OnCaptchaValidate="RadCaptcha1_CaptchaValidate">
            <CaptchaImage ImageCssClass="imageClass" BackgroundColor="#dff3ff" TextColor="Black"
        Enter the sum of the digits in the validation code
        <br />
        (enter 0 if there are no digits):<br />
        <asp:TextBox ID="ValdiationCodeDigitsSum" runat="server"></asp:TextBox>
        <div style="margin-top: 15px;">
            <asp:Button ID="btnValidate" runat="server" Text="Verify Code" ValidationGroup="Group">

Support & Learning Resources

Find Assistance