Back to Devexpress

ASPxCaptcha Class

aspnet-devexpress-dot-web-c52e5e71.md

latest8.6 KB
Original Source

ASPxCaptcha Class

A control used for the challenge-response authentication.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class ASPxCaptcha :
    ASPxWebControl,
    IRequiresLoadPostDataControl
vb
Public Class ASPxCaptcha
    Inherits ASPxWebControl
    Implements IRequiresLoadPostDataControl

Remarks

The ASPxCaptcha class implements the functionality of a challenge-response authentication test, which enables verifying that submitted data came from a human, and not a robot or script.

Create a Captcha Control

Design Time

The ASPxCaptcha control is available on the DX.25.2: Common Controls toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control’s settings, or paste the control’s markup in the page’s source code.

aspx
<dx:ASPxCaptcha ID="Captcha" runat="server" ClientInstanceName="ClientCaptcha">
    <TextBox Position="Bottom" />
    <ValidationSettings SetFocusOnError="true" ErrorDisplayMode="ImageWithText" />
</dx:ASPxCaptcha>

Run Time

csharp
using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxCaptcha captcha = new ASPxCaptcha();
    captcha.ID = "Captcha";
    Page.Form.Controls.Add(captcha);

    captcha.ClientInstanceName = "ClientCaptcha";
    captcha.TextBox.Position = DevExpress.Web.Captcha.ControlPosition.Bottom;
    captcha.ValidationSettings.SetFocusOnError = true;
    captcha.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
}
vb
Imports DevExpress.Web

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim captcha As ASPxCaptcha = New ASPxCaptcha()
    captcha.ID = "Captcha"
    Page.Form.Controls.Add(captcha)

    captcha.ClientInstanceName = "ClientCaptcha"
    captcha.TextBox.Position = DevExpress.Web.Captcha.ControlPosition.Bottom
    captcha.ValidationSettings.SetFocusOnError = True
    captcha.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText
End Sub

Note

DevExpress controls require that you register special modules, handlers, and options in the Web.config file. You can change this file or switch to the Design tab in the Microsoft Visual Studio IDE to automatically update the Web.config file. Note that this information is automatically registered if you use the DevExpress Template Gallery to create a project.

The ASPxCaptcha control uses a session state to store a verification code. Therefore, the session state mode attribute should not be Off for the control to operate properly.

The control consists of the following elements:

Note

The ASPxCaptcha control provides you with comprehensive client-side functionality, implemented using JavaScript code:

The control’s client-side API is enabled if the ASPxCaptcha.ClientInstanceName property is defined, or any client event is handled.

Implements

Show 14 items

IComponent

IDisposable

IParserAccessor

IDataBindingsAccessor

IControlBuilderAccessor

IControlDesignerAccessor

IExpressionsAccessor

IAttributeAccessor

IUrlResolutionService

INamingContainer

IPostBackDataHandler

IPostBackEventHandler

ICallbackEventHandler

IPropertiesOwner

Inheritance

Object Control WebControl ASPxWebControlBase ASPxWebControl ASPxCaptcha MVCxCaptcha

See Also

ASPxCaptcha Members

Captcha Control

DevExpress.Web Namespace