New to Telerik UI for ASP.NET MVC? Start a free 30-day trial

Defines the fluent API for configuring the Telerik UI for ASP.NET MVC Captcha.

Definition

Constructors

Initializes a new instance of the Captcha class.

C#
public CaptchaBuilder(Captcha component)
Parameters:componentCaptcha

The component.

Methods

Toggles the audio button.

C#
public CaptchaBuilder AudioButton(bool value)
Parameters:valuebool

The value that configures the visibility of the audio button.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.AudioButton(false)
)

The URL or AJAX settings that fetches the audio of the captcha.

C#
public CaptchaBuilder AudioHandler(Action<CrudOperationBuilder> configurator)
Parameters:configuratorAction<CrudOperationBuilder>

The action that configures the audio settings.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.AudioHandler(x =&gt; x.Action("GetAudio","Captcha").Data("additionalParameters"))
)

Defines the URL that fetches the audio of the captcha.

C#
public CaptchaBuilder AudioHandler(string url)
Parameters:urlstring

The URL that returns the audio source.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.AudioHandler("url-to-audio")
)

The JavaScript function that fetches the audio of the captcha. Within the function, call the "args.success" method with the source of the audio (base64 stream).

C#
public CaptchaBuilder AudioHandlerFunction(string handler)
Parameters:handlerstring

The JavaScript function that returns the source of the audio.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.AudioHandlerFunction("audioHandler")
)
&lt;script&gt;
function audioHandler(args) {
args.success("@Url.Action("GetAudio", "Captcha")?captchaId=" + args.data.CaptchaID);
}
&lt;/script&gt;

Defines the ID of the captcha that initially must be displayed. The ID will be stored in the hidden input. If the CaptchaId() is not set, the Handler() option will initiate a request to the remote endpoint to retrieve the captcha ID.

C#
public CaptchaBuilder CaptchaId(string value)
Parameters:valuestring

The value that configures the captcha ID.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.CaptchaId((string)ViewData["CaptchaID"])
)

Defines the image source that initially must be rendered as captcha. If the CaptchaImage() is not set, the Handler() option will initiate a request to the remote endpoint to retrieve the image.

C#
public CaptchaBuilder CaptchaImage(string captchaImage)
Parameters:captchaImagestring

The value that configures the initial image.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.CaptchaImage((string)ViewData["Captcha"])
)

Sets the name of the field that holds the captcha's image source. It is used in the Handler() option that resets the captcha's image and ID.

C#
public CaptchaBuilder DataCaptchaField(string value)
Parameters:valuestring

The value that configures the DataCaptchaField.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.DataCaptchaField("CaptchaImage")
)

Sets the name of the field that holds the captcha's ID. It is used in the Handler() option that resets the captcha's image and ID.

C#
public CaptchaBuilder DataCaptchaIdField(string value)
Parameters:valuestring

The value that configures the DataCaptchaIdField.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.DataCaptchaIdField("CaptchaID")
)

Handles the client-side events of the Captcha.

C#
public CaptchaBuilder Events(Action<CaptchaEventBuilder> configurator)
Parameters:configuratorAction<CaptchaEventBuilder>

The action that configures the available events.

Returns:

CaptchaBuilder

Example:
C#
@( Html.Kendo().Captcha()
.Name("captcha")
.Events(events =&gt; events.Change("onChange"))
)

Defines the URL or AJAX settings that fetches the captcha image and id. The request triggers initially when the CaptchaImage() and CaptchaId() options are not defined to request the captcha and when the "Reset" button is clicked.

C#
public CaptchaBuilder Handler(Action<CrudOperationBuilder> configurator)
Parameters:configuratorAction<CrudOperationBuilder>

The action that configures the endpoint to return the image initially or when resetting the Captcha.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.Handler(handler =&gt; handler.Action("GetCaptcha", "Captcha").Data("additionalParameters"))
)

Defines the URL that fetches the captcha image and id.

C#
public CaptchaBuilder Handler(string url)
Parameters:urlstring

The URL that returns the captcha image and id.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.Handler("url-to-captcha")
)

The JavaScript function that fetches the captcha image and id. Within the function, call the "args.success()" method with the received captcha image and id.

C#
public CaptchaBuilder HandlerFunction(string handler)
Parameters:handlerstring

The JavaScript function that returns the captcha image and id.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.DataCaptchaField("Captcha")
.DataCaptchaIdField("CaptchaID")
.HandlerFunction("getCaptcha")
)
&lt;script&gt;
function getCaptcha(args) {
$.ajax({
type: "GET",
url: '@Url.Action("Reset","Captcha")',
success: function(data) {
args.success({
Captcha: data.Captcha,
CaptchaID: data.CaptchaID
});
}
});
}
&lt;/script&gt;

Defines the localization of the texts that are used in the Captcha.

C#
public CaptchaBuilder Messages(Action<CaptchaMessagesSettingsBuilder> configurator)
Parameters:configuratorAction<CaptchaMessagesSettingsBuilder>

The action that configures the messages settings.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.Messages(msg =&gt; msg.Success("Successful Verification").Audio("Play captcha"))
)

Toggles the reset button.

C#
public CaptchaBuilder ResetButton(bool value)
Parameters:valuebool

The value that configures the visibility of the reset button.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.ResetButton(false)
)

Defines whether to trigger the validation when the input is blurred. This option is useful when the Kendo UI Validator or the Telerik UI Form are not used, as it automatically triggers the remote validation.

C#
public CaptchaBuilder ValidateOnBlur(bool value)
Parameters:valuebool

The value that enables the validation on blur.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.ValidateOnBlur(true)
)

Defines the URL or AJAX settings that validates the text input of the Captcha.

C#
public CaptchaBuilder ValidationHandler(Action<CrudOperationBuilder> configurator)
Parameters:configuratorAction<CrudOperationBuilder>

The action that configures the validation of the Captcha.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.ValidationHandler(handler =&gt; handler.Action("ValidateCaptcha", "Captcha"))
)

Defines the URL of the endpoint that validates the text input of the Captcha.

C#
public CaptchaBuilder ValidationHandler(string url)
Parameters:urlstring

The URL of the endpoint.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.ValidationHandler("url-to-validate-captcha")
)

The JavaScript function that validates the text input of the Captcha. Within the function, call the "args.success()" method with the boolean value indicating whether the validation passed successfully.

C#
public CaptchaBuilder ValidationHandlerFunction(string handler)
Parameters:handlerstring

The JavaScript function that validates the Captcha.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.DataCaptchaField("Captcha")
.DataCaptchaIdField("CaptchaID")
.ValidationHandlerFunction("validateCaptcha")
)
&lt;script&gt;
function validateCaptcha(args) {
$.ajax({
type: "GET",
url: `captcha/validate?CaptchaID=${args.data.CaptchaID}&amp;Captcha=${args.data.Captcha}`,
success: function(result) {
args.success(result);
}
});
}
&lt;/script&gt;

Toggles the volume control button when the audio is played.

C#
public CaptchaBuilder VolumeControl(bool value)
Parameters:valuebool

The value that configures the visibility of the volume control button.

Returns:

CaptchaBuilder

Example:
C#
@(Html.Kendo().Captcha()
.Name("captcha")
.VolumeControl(false)
)