Load events into calendar RRS feed

  • Question

  • User158034481 posted

    Hi, I have this implemented and it works great http://arshaw.com/fullcalendar/. I want to load my events from either a .ashx file or .asmx file and I can't seem to figure it out for the life of me. When I hard code the events in the javascript everything works great, but when I try to return the events from a .ashx or .asmx file it doesn't work at all. What am I doing wrong? The code hits my breakpoint on my function in the .ashx and I get no errors. Here is my .ashx example:

    <script type='text/javascript'>
            $(document).ready(function () {
                var date = new Date();
                var d = date.getDate();
                var m = date.getMonth();
                var y = date.getFullYear();
                var calendar = $('#calendar').fullCalendar({
                    header: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay'
                    selectable: true,
                    selectHelper: true,
                    select: function (start, end, allDay) {
                        var title = prompt('Event Title:');
                        if (title) {
    						    title: title,
    						    start: start,
    						    end: end,
    						    allDay: allDay
    						true // make the event "stick"
                    editable: true,
                    events: "Handler1.ashx"
    //Here is the .ashx function that gets called
     public void ProcessRequest(HttpContext context)
                context.Response.ContentType = "application/json";
                context.Response.Write("[{title: 'Long Event', start: '2013-02-05', end: '2013-02-23'}]");

    Saturday, February 23, 2013 5:44 PM

All replies

  • User-742633084 posted

    Hi epatmalnieks,

    If I understand correctly, what you need is to achieve the goal of the following demo page:


    in the above sample page, it load external events (via js code) from the "json-events.php". So you can just use fiddler or IE development tool bar to capture the HTTP response content of the "json-events.php" request to see what kind of data it returns. Based on my local test, here is the response data I've got via IE dev toolbar:


    So what the json-events.php returns is just a JSON array. Then, what you need to do is let your ASP.NET httphandler or even a simple ASP.NET page return the same format JSON data.

    #HTTPHandler with JSON Data

    To generate JSON data in server-side .NET code, you can use various means such as:

    • Directly compose JSON string via stringBuilder class
    • Use DataContractJsonSerializer or JavaScriptSerializer to convert .NET object to JSON string

    #An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET


    Wednesday, March 6, 2013 10:16 PM