The Calendar Web control, like all Web controls, allows you to use styles to specify the appearance of the control, including aspects such as font, color, borders, and so on. For general information about using styles with Web controls, see Customizing Control Appearance Using Styles.
Note Styles are not fully supported in all browsers.
To allow you flexibility in customizing the appearance of the calendar output, the Calendar Web control supports styles for a number of discrete elements that make up the calendar grid. The following diagram of a calendar with all optional elements displayed.
The following table describes each of the elements that you can control using styles.
Calendar Element | Description |
---|---|
DayStyle | Days of the current month. Weekends, today, and the selected day can have different styles (see below). |
DayHeaderStyle | Row above the calendar where the names of the days appear. |
NextPrevStyle | Sections at the left and right ends of the title bar where the month navigation LinkButtons are. |
OtherMonthDayStyle | Days from the previous and next month that appear on the current month view. |
SelectedDayStyle | The day selected by the user. |
SelectorStyle | The column to the left containing links for selecting a week or the whole month. |
TitleStyle | Titlebar at the top of the calendar containing the month name and month navigation links. If NextPrevStyle is set, it overrides the extreme ends of the title bar. |
TodayDayStyle | Today's date. |
WeekendDayStyle | Weekend days. |
To set calendar element styles in the .aspx file
<asp:WebCalendar>
), include the style information using the following syntax:
StyleElementName-Style="value"
The following examples illustrate style settings for the DayStyle and TitleStyle elements:
<asp:WebCalendar id="Calendar1" runat="server" SelectionMode="DayWeek"
DayStyle-BackColor="white" TitleStyle-ForeColor="black"
>
</asp:WebCalendar>
To set calendar element styles programmatically
Calendar1.StyleName.Property = setting
The following examples illustrate some typical style settings for the Calendar control:
[VB]
Calendar1.DayStyle.FontSize = new FontUnit(10)
Calendar1.TitleStyle.ForeColor = new Color("red")
Note For details about setting properties, see Getting and Setting Web Form Control Values.
See Also
Customizing Control Appearance Using Styles | Using the Calendar Web Control