asp.net - Full Calender is not rendering events? -


events not rendering in fullcalender?

var calendar = $('#calendar').fullcalendar({     theme: true,     header: {         left: 'prev,next today',         center: 'title',         right: 'month,agendaweek,agendaday'     },     //events: '/mycalender/jsonresponse.ashx',     events: [{id: '1',title: 'event1',start:  1312462800,end: 1312462800,allday:false,description: 'event1'},{id: '3',title: 'event2',start:  1309890600,end: 1309890600,allday:true,description: 'event2'},{id: '4',title: 'event5',start:  1311705000,end: 1311705000,allday:true,description: 'event5'},{id: '5',title: 'event3',start:  1310927400,end: 1310927400,allday:true,description: 'event3'},{id: '6',title: 'event4',start:  1310495400,end: 1310495400,allday:true,description: 'event4'},{id: '7',title: 'time event1',start:  1312144200,end: 1312174800,allday:false,description: 'time event1'}],     ..other parameter                     ... }); 

i using following code (ashx file ) call events data..

public void processrequest(httpcontext context)     {         context.response.contenttype = "application/json";          datetime start = new datetime(1970, 1, 1);         datetime end = new datetime(1970, 1, 1);          start = start.addseconds(double.parse(context.request.querystring["start"]));         end = end.addseconds(double.parse(context.request.querystring["end"]));           string result = string.empty;          result += "[";          list<int> idlist = new list<int>();         foreach (calendarevent cevent in eventdal.getevents(start, end))         {             result += convertcalendareventintostring(cevent);             idlist.add(cevent.id);         }          if (result.endswith(","))         {             result = result.substring(0, result.length - 1);         }          result += "]";         //store list of event ids in session, can accessed in web methods         context.session["idlist"] = idlist;          context.response.write(result);     }      private string convertcalendareventintostring(calendarevent cevent)     {         string allday = "true";         if (converttotimestamp(cevent.start).tostring().equals(converttotimestamp(cevent.end).tostring()))         {              if (cevent.start.hour == 0 && cevent.start.minute == 0 && cevent.start.second == 0)             {                 allday = "true";             }             else             {                 allday = "false";             }         }         else         {             if (cevent.start.hour == 0 && cevent.start.minute == 0 && cevent.start.second == 0                 && cevent.end.hour == 0 && cevent.end.minute == 0 && cevent.end.second == 0)             {                 allday = "true";             }             else             {                 allday = "false";             }         }         return "{" +                   "id: '" + cevent.id + "'," +                   "title: '" + httpcontext.current.server.htmlencode(cevent.title) + "'," +                   "start:  " + converttotimestamp(cevent.start).tostring() + "," +                   "end: " + converttotimestamp(cevent.end).tostring() + "," +                   "allday:" + allday + "," +                   "description: '" + httpcontext.current.server.htmlencode(cevent.description) + "'" +                   "},";     }       public bool isreusable     {                 {             return false;         }     }      private long converttotimestamp(datetime value)     {         long epoch = (value.touniversaltime().ticks - 621355968000000000) / 10000000;         return epoch;     }   

after trial , error here observations:

double quotes around name , value works me eg. "id" : "1" .the names in code don't have closing double quotes , values in single quotes. try double quotes

the start , end date value need in seconds. i'm not familiar .net can't make out if converttotimestamp returns seconds or millisecs. value should in double quotes.

can try above suggestions , see if work you?


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -