Skip to content

<Captcha>

The Captcha tag renders a CAPTCHA challenge — an image of distorted characters the user must read and type — to help confirm the user is human. If your forms are public, web bots will eventually find them and submit junk; a CAPTCHA reduces the frequency of those submissions.

NOTE

Due to a limitation in the underlying DNN CAPTCHA control, this tag can only be used in the FormView module.

Example

html
<AddForm>
  ...
  <table>
    <tr>
      <td>
        <Label For="txtFirstName" Text="First Name" />
        <Textbox id="txtFirstName" DataField="FirstName" DataType="string" />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="txtLastName" Text="Last Name" />
        <Textbox Id="txtLastName" DataField="LastName" DataType="string" />
       </td>
    </tr>
    <tr>
      <td>
        <Captcha CaptchaLength="5" />
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <AddButton Text="Add"/>&nbsp; <CancelButton Text="Cancel"/>
      </td>
    </tr>
  </table>
</AddForm>

Properties

PropertyValuesDefaultDescription
ID *stringUnique identifier for the control within the form
AccessKeystringKeyboard shortcut character (e.g. F for Alt+F)
BackgroundColorcolor name | #ddddddBackground color used behind the CAPTCHA characters
BackgroundImageURLURL to an image file used as the background behind the characters
CaptchaCharsstringabc...XYZ23456789Character set used to generate the challenge text
CaptchaHeightsize100pxHeight of the CAPTCHA image
CaptchaLengthinteger6Number of characters in the challenge
CaptchaWidthsize300pxWidth of the CAPTCHA image
CssClassstringCSS class name(s) for styling the control
EnabledTrue FalseTrueWhen False, the control is disabled (grayed out and not interactive)
ErrorMessagestring(localized)Message shown to the user if their input does not match the challenge
ErrorStylestyle attributesStyling for the error message — uses ASP.NET nested style syntax (e.g. ErrorStyle-ForeColor="red")
Expirationinteger (seconds)120How long the challenge remains valid before it must be regenerated
HeightsizeHeight of the control
StylestringInline CSS (e.g. color: red; border: solid 1px black;)
TabIndexintegerTab order for keyboard navigation
Textstring(localized)Caption displayed next to the CAPTCHA image (e.g. "Enter the code shown above")
ToolTipstringText displayed on mouse hover
VisibleTrue FalseTrueShows or hides the control
WidthsizeWidth of the control

* Required property

Deprecated Properties

These properties use ASP.NET inline styling and are no longer recommended for modern web development. Use the CssClass property to apply CSS classes or the Style property for inline CSS instead.

PropertyValuesDescription
BackColorcolor name | #ddddddBackground color of the control
BorderColorcolor name | #ddddddBorder color of the control
BorderStyleNotSet None Dotted Dashed Solid Double Groove Ridge Inset OutsetBorder style of the control
BorderWidthsizeBorder width of the control
Font-BoldTrue FalseBold text
Font-ItalicTrue FalseItalic text
Font-NamesstringFont family name
Font-OverlineTrue FalseOverline text decoration
Font-SizeXX-Small X-Small Small Medium Large X-Large XX-Large or sizeFont size
Font-StrikeoutTrue FalseStrikethrough text decoration
Font-UnderlineTrue FalseUnderline text decoration
ForeColorcolor name | #ddddddText color of the control

The ErrorStyle property accepts the same set of nested style attributes (e.g. ErrorStyle-Font-Bold, ErrorStyle-ForeColor). These are likewise deprecated — prefer styling the error message via CSS targeting the rendered error element.

Property Details

  • ID: Name, consisting of letters and numbers, beginning with a letter, that uniquely identifies the control within the form.

  • CaptchaChars: The pool of characters from which challenge text is randomly drawn. The default set deliberately omits visually ambiguous characters (such as O, 0, I, 1) to reduce user errors. Override this only if you have a specific reason — for example, to limit the challenge to digits or to avoid characters that don't render well in your chosen font.

  • ErrorStyle: Styling for the error message displayed when the user's input doesn't match the challenge. Uses ASP.NET nested style syntax: prefix any deprecated style attribute with ErrorStyle- (e.g. ErrorStyle-ForeColor="red", ErrorStyle-Font-Bold="True"). For modern styling, prefer CSS targeting the rendered error element.