Prop Webcontrol Calendar Selecteddaystyle
## ASP.NET Calendar SelectedDayStyle Property
The `SelectedDayStyle` property is used to get or set the style of the currently selected day (or days) in an ASP.NET `Calendar` control.
By customizing this property, you can visually distinguish the selected date from other dates on the calendar using custom background colors, fonts, borders, and more.
---
## Syntax and Usage
You can define the `SelectedDayStyle` property in two ways within your `.aspx` markup:
### Option 1: Inner Property Tag (Recommended for multiple styles)
```xml
```
### Option 2: Inline Attribute (Recommended for single styles)
```xml
```
### Property Values
| Attribute | Description |
| :--- | :--- |
| `style` | Specifies the style property you want to set (e.g., `BackColor`, `ForeColor`, `Font-Bold`, `BorderWidth`). For a complete list of applicable style attributes, refer to the standard ASP.NET WebControl Style properties. |
| `value` | Specifies the value to apply to the chosen style property (e.g., `#FF0000`, `True`, `1px`). |
---
## Code Examples
### Example 1: Using the Inner Property Tag
This example demonstrates how to set the text color of the selected day to red using the inner `` tag.
```xml
```
### Example 2: Using the Inline Attribute
This example achieves the exact same visual result as Example 1, but uses the inline hyphenated attribute syntax.
```xml
```
### Example 3: Advanced Styling (Multiple Properties)
In real-world scenarios, you will often want to change multiple style properties at once to make the selected day stand out clearly.
```xml
```
---
## Key Considerations
1. **Precedence**: If you set styles on individual days programmatically during the `DayRender` event, those styles might override the styles defined in `SelectedDayStyle`.
2. **Selection Mode**: The `SelectedDayStyle` is only visible when the user selects a date. Ensure that the `SelectionMode` property of your `Calendar` control is set to something other than `CalendarSelectionMode.None` (the default is `Day`, which allows selecting a single day).
3. **CSS Classes**: Instead of hardcoding inline styles, you can also use the `CssClass` property inside the `SelectedDayStyle` tag (e.g., ` `) to keep your design consistent with external stylesheets.
YouTip