The calendar shows a complete month and supports the display of calendar entries like appointments or meetings.
In order to show a calendar in your view, just add the following HtmlHelper:

<%= Html.Calendar(Model.Year, Model.Month)

The calendar extension method expects 2 parameters. One for the year, and the second for the month to display. In the example these values are provided in the view model.

The following options are available:
  • FirstDayInWeek(): Lets you specify the first weekday. The default is DayOfWeek.Monday. Sorry USA, I live in Europe, and it's my default value :-)
  • HighlightToday(): If this is called, the current date cell will be decorated with the "today" CSS class, allowing you to highlight it. If you omit this call, the current day won't be highlighted.
  • ShowPrevNextMonth() If this method is called, the days from the last and next month will be shown as well. If you omit this all, the according cells will be empty.
  • DayUrl(): Lets you specify an URL to a detail page for a specific day. If you omit this, then the day numbers will be rendered as text only.
  • The Entries() method expects an IEnumerable<ICalendarEntry>. You can add these to your view model in the controller. A calendar entry has got properties for the date, the title and an URL.

Last edited Oct 15, 2009 at 3:25 PM by kherzam, version 4


No comments yet.