search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Using MVC Calendar

Asked by Todd Barchok
9 years ago.
I've been looking into migrating a calendar control we use on our company site from the ASP.NET Lite to the ASP.NET MVC Pro, but I'm running into problems, and have a few questions. First: How can I limit the hours displayed? I can set DaysBeginHour, but there's no way to set the end time, and BusinessEndsHour doesn't accomplish what I want. I don't need to display a full 24 hours. Second: How can I pass in parameters to the initialisation function? It's rather important, since I need to use those to generate a list of events. Maybe it's obvious to someone who is more familiar with MVC controls, but the current documentation and tutorials are lacking. Thanks
Answer posted by Todd Barchok
9 years ago.

After a bit of work, I've answered both these questions myself. Limiting hours displayed can be accomplished by setting HeightSpec = HeightSpec.BusinessHoursNoScroll

Passing in data to the calendar object involved a bit of work, but the eventual solution was to pass arguments into the constructor for the 'Dpc' class that is used in the examples, and storing those as protected members of that class.

Answer posted by Dan Letecky
9 years ago.

Thanks for posting your solution.

There is also another option which will allow you to show 24 hours but starting at the specified hour:

DayBeginsHour = 6

This will move the day start from 00:00 to 06:00.

Loading the events should be quite straightforward. You should be able to use any class that is IEnumerable in the Events property. Unless you have special needs, it's enough to load it inside Dpc class, e.g. in the OnFinish() overload. See also here (demonstrated for the Month control):

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.