Skip to content

<CalendarButton>

The CalendarButton tag renders a push-button that opens a pop-up date-picker. When the user picks a date, it's written into the target control (typically a <TextBox>). Use <CalendarImage> for an image trigger or <CalendarLink> for a hyperlink that does the same thing.

Validation is skipped

CalendarButton sets CausesValidation="False" automatically, so opening the calendar won't trigger client-side validation on the form. (For an alternative date entry experience that does validate, see <DateInput>.)

Example

html
<AddForm>
  <SubmitCommand CommandText="INSERT INTO Events(EvtDate) VALUES(@EvtDate)" />
  <table>
    <tr>
      <td>
         <Label For="txtEventDate" Text="Event Date" />
         <TextBox Id="txtEventDate" DataField="EvtDate" DataType="datetime" />
         <CalendarButton Text="Select Date" Target="txtEventDate" Format="yyyy-MM-dd" />
       </td>
    </tr>
    <tr>
      <td colspan="2"><AddButton Text="Add"/> <CancelButton Text="Cancel"/></td>
    </tr>
  </table>
</AddForm>

Properties

PropertyValuesDefaultDescription
Target *control IDID of the control (typically a <TextBox>) that will receive the selected date
TextstringCaption displayed on the button
AccessKeystringKeyboard shortcut character (e.g. F for Alt+F)
CssClassstringCSS class name(s) for styling the control
EnabledTrue FalseTrueWhen False, the control is disabled (grayed out and not interactive)
Formatdate format stringFormat string used when writing the selected date into the target. If omitted, the server's short date format is used
HeightsizeHeight of the control
IDstringUnique identifier for the control within the form
StylestringInline CSS (e.g. color: red; border: solid 1px black;)
TabIndexintegerTab order for keyboard navigation
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

Property Details

  • Target: The ID of the form control that will receive the selected date — typically a <TextBox>. The control must be in the same form as the calendar trigger.

  • Format: A .NET date format string used to write the selected date into the target control. If omitted, the server's short date format is used. Common patterns: yyyy-MM-dd (ISO date), MM/dd/yyyy (US), dd/MM/yyyy (UK). If you need to enforce that format on submission, pair the target textbox with a <Validate Type="regex"> rule.