Back to Devexpress

CaptchaImageProperties.FontFamily Property

aspnet-devexpress-dot-web-dot-captcha-dot-captchaimageproperties-b6894042.md

latest3.6 KB
Original Source

CaptchaImageProperties.FontFamily Property

Gets or sets a font family used within the challenge image

Namespace : DevExpress.Web.Captcha

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("Times New Roman")]
public string FontFamily { get; set; }
vb
<DefaultValue("Times New Roman")>
Public Property FontFamily As String

Property Value

TypeDefaultDescription
String"Times New Roman"

A string which specifies the font family of the challenge image.

|

Example

The following part of the ASPxCaptcha - Features online demo illustrates how to customize the challenge image‘s style settings.

These settings are specified within a panel (ASPxComboBox, ASPxColorEdit editors) and applied to the captcha control via the Apply button (ASPxButton).

csharp
protected void btnApply_Click(object sender, EventArgs e) {
...
    int parseResult = 0;
    Captcha.ChallengeImage.FontFamily = cbFontFamily.Value.ToString();
    Captcha.ChallengeImage.ForegroundColor = ceForegroundColor.Color;
    Captcha.ChallengeImage.BackgroundColor = ceBackgroundColor.Color;
    Captcha.ChallengeImage.BorderColor = ceBorderColor.Color;
    if (int.TryParse(seBorderWidth.Text, out parseResult))
        Captcha.ChallengeImage.BorderWidth = parseResult;
...
}
aspx
<dx:ASPxCaptcha ID="Captcha" runat="server" Width="402px">
    <ValidationSettings ErrorDisplayMode="Text">
    </ValidationSettings>
</dx:ASPxCaptcha>
...
<dx:ASPxComboBox ID="cbFontFamily" runat="server" Width="170px" ValueType="System.String">
    <Items>
        <dx:ListEditItem Text="Times New Roman" Value="Times New Roman" />
        <dx:ListEditItem Text="Courier New" Value="Courier New" />
        <dx:ListEditItem Text="Georgia" Value="Georgia" />
        <dx:ListEditItem Text="Tahoma" Value="Tahoma" />
        <dx:ListEditItem Text="Verdana" Value="Verdana" />
    </Items>
</dx:ASPxComboBox>
...
<dx:ASPxColorEdit ID="ceForegroundColor" runat="server" Width="170px">
</dx:ASPxColorEdit>
...
<dx:ASPxColorEdit ID="ceBackgroundColor" runat="server" Width="170px">
</dx:ASPxColorEdit>
...
<dx:ASPxColorEdit ID="ceBorderColor" runat="server" Width="170px">
</dx:ASPxColorEdit>
...
<dx:ASPxSpinEdit ID="seBorderWidth" Width="50px" runat="server" MaxValue="10">
</dx:ASPxSpinEdit>
...
<dx:ASPxButton ID="btnApply" CssClass="DemoButton" runat="server" Text="Apply" 
Width="70px" OnClick="btnApply_Click" />

See Also

Captcha Control

CaptchaImageProperties Class

CaptchaImageProperties Members

DevExpress.Web.Captcha Namespace