YouTip LogoYouTip

Prop Webcontrol Calendar Daystyle

## ASP.NET Calendar DayStyle Property The **DayStyle** property is used to get or set the style of the individual days within an ASP.NET `Calendar` control. This property allows you to customize the appearance of standard days (such as their background color, font, border, and text color) to match your web application's design. --- ## Syntax and Usage You can define the `DayStyle` property in two different ways within your ASP.NET markup: ### Method 1: Inner Tag Syntax (Sub-element) This method uses a nested `` tag inside the `` control declaration. ```xml ``` ### Method 2: Attribute Prefix Syntax (Inline) This method uses the `DayStyle-` prefix directly on the `` tag. ```xml ``` ### Property Values | Attribute | Description | | :--- | :--- | | `style` | Specifies the style property you want to set (e.g., `ForeColor`, `BackColor`, `Font-Bold`, `BorderWidth`). For a complete list of applicable style properties, refer to the standard (#style-properties-reference). | | `value` | Specifies the value to assign to the chosen style property (e.g., `#FF0000`, `12pt`, `true`). | --- ## Code Examples Below are two practical examples demonstrating how to set the `DayStyle` property to change the text color of the days to red (`#FF0000`). ### Example 1: Using the Inner Tag Syntax This approach is highly readable and is recommended when you need to configure multiple style properties (such as font, background, and borders) simultaneously. ```xml
``` ### Example 2: Using the Inline Attribute Prefix Syntax This approach is more compact and is ideal for quick, single-property style changes. ```xml
``` --- ## Style Properties Reference The `DayStyle` property returns a `TableItemStyle` object. You can customize the days using any of the following common style attributes: * **`BackColor`**: Sets the background color of the days. * **`ForeColor`**: Sets the text color of the days. * **`Font-Name` / `Font-Size` / `Font-Bold`**: Customizes the typography of the day numbers. * **`BorderColor` / `BorderStyle` / `BorderWidth`**: Configures the borders surrounding each day cell. * **`Height` / `Width`**: Defines the dimensions of the day cells. ### Style Precedence Note In the ASP.NET `Calendar` control, styles are applied in a specific order of precedence. The `DayStyle` property defines the default style for all days. However, more specific style propertiesβ€”such as `WeekendDayStyle`, `TodayDayStyle`, or `SelectedDayStyle`β€”will override the settings defined in `DayStyle` if they overlap.
← Prop Webcontrol Calendar FirstProp Webcontrol Calendar Capti β†’