YouTip LogoYouTip

Prop Webcontrol Calendar Titleformat

## ASP.NET Calendar TitleFormat Property The `TitleFormat` property is a member of the ASP.NET Web Control `Calendar` class. It is used to get or set the display format of the calendar's title section (the header that displays the month and year). --- ## Definition and Usage The `TitleFormat` property determines how the month and year are formatted and presented at the top of the Calendar control. By changing this property, you can control whether the header displays only the month name or both the month and the year. --- ## Syntax ```xml ``` ### Property Values | Value | Description | | :--- | :--- | | **`Month`** | Displays only the name of the month (e.g., "January"). | | **`MonthYear`** | Displays both the month and the year (e.g., "January 2026"). This is the **default** value. | --- ## Code Examples ### Example 1: Setting TitleFormat to "Month" The following example demonstrates how to configure the Calendar control to display only the month name in its title bar. ```xml <%@ Page Language="C#" %> Calendar TitleFormat Example

Calendar TitleFormat: Month

``` ### Example 2: Setting TitleFormat Programmatically You can also dynamically change the `TitleFormat` property in your code-behind file (C#) based on user interaction or application logic. ```csharp // Set the title format to display both Month and Year programmatically cal1.TitleFormat = TitleFormat.MonthYear; ``` --- ## Considerations and Best Practices 1. **Default Behavior**: If you do not explicitly define the `TitleFormat` attribute, the calendar defaults to `MonthYear`. 2. **Localization**: The actual text displayed for the month and year automatically adapts to the current culture settings (`CultureInfo`) of the application thread or the user's browser locale. 3. **Styling**: The appearance of the title text (such as font, color, and background) can be further customized using the `` sub-element of the `Calendar` control.
← Prop Webcontrol Calendar TitleProp Webcontrol Calendar Showt β†’