Back to Devexpress

ASPxCaptcha.CharacterSet Property

aspnet-devexpress-dot-web-dot-aspxcaptcha-be4065e5.md

latest3.4 KB
Original Source

ASPxCaptcha.CharacterSet Property

Gets or sets the set of characters used by the editor to generate the code displayed on the challenge image.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("abcdefhjklmnpqrstuvxyz23456789")]
public string CharacterSet { get; set; }
vb
<DefaultValue("abcdefhjklmnpqrstuvxyz23456789")>
Public Property CharacterSet As String

Property Value

TypeDefaultDescription
String"abcdefhjklmnpqrstuvxyz23456789"

A String value that specifies the set of characters.

|

Remarks

Use the CharacterSet property to specify the allowed characters (as a sequence of characters) for generating the code displayed on the editor’s challenge image.

Example

The following part of the ASPxCaptcha - Features online demo illustrates how to customize the characters set used to generate the challenge image’s code (ASPxCaptcha.CharacterSet) and specify this code length (ASPxCaptcha.CodeLength).

This settings are specified within a panel (ASPxTextBox, ASPxSpinEdit editors) and applied to the captcha control via the Apply button (ASPxButton).

csharp
protected void btnApply_Click(object sender, EventArgs e) {
...
    int parseResult = 0;
    if(tbCharacterSet.IsValid)
        Captcha.CharacterSet = tbCharacterSet.Text;
    if (int.TryParse(seCodeLength.Text, out parseResult))
        Captcha.CodeLength = parseResult;
...
}
aspx
<dx:ASPxCaptcha ID="Captcha" runat="server" Width="402px">
    <ValidationSettings ErrorDisplayMode="Text"></ValidationSettings>
</dx:ASPxCaptcha>
...
<dx:ASPxLabel EnableViewState="False" ID="lblCharacterSet" AssociatedControlID="tbCharacterSet" 
runat="server" Text="Character set:" />
...
<dx:ASPxTextBox ID="tbCharacterSet" runat="server" 
Width="200px" MaxLength="50">
    <ValidationSettings>
        <RequiredField IsRequired="True" ErrorText="A character set is required" />
    </ValidationSettings>
</dx:ASPxTextBox>
...
<dx:ASPxLabel EnableViewState="False" ID="lblCodeLength" AssociatedControlID="seCodeLength" 
runat="server" Text="Code length:" />
...
<dx:ASPxSpinEdit ID="seCodeLength" Width="50px" runat="server" 
MinValue="3" MaxValue="7"></dx:ASPxSpinEdit>
...
<dx:ASPxButton ID="btnApply" CssClass="DemoButton" runat="server" 
Text="Apply" Width="70px" OnClick="btnApply_Click" />
...

See Also

Captcha Control

ASPxCaptcha Class

ASPxCaptcha Members

DevExpress.Web Namespace