Click here to Skip to main content
15,883,647 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HomeController

C#
public ActionResult CalendarData()
        {
            var events = new[]
        {
            new { title = "Fremvising", start = "2014-04-08", end = "2014-04-10", editable = true },
            new { title = "Second Title Event", start = "2014-04-09T15:09:00Z", end = "2014-04-11T17:10:00Z", editable = true }
      
        };
            return Json(events, JsonRequestBehavior.AllowGet);
        }



Index.CSHTML

C#
function InitializeCalendar() {
            $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'agendaDay,agendaWeek,month'
                },
                editable: true,
                events: function (start,end,callback) {
                    $.getJSON('@Url.Action("CalendarData", "Home")',
                    function (locationsArray) {
                        alert(locationsArray);
                        var events = $(locationsArray).map(function () {
                            return {

                                title: this.title,
                                start: this.start,
                                end: this.end,
                                allDay: this.editable
                            }
                        }).toArray();
                        callback(events);
                    });
                }
            });
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900