Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>At the end, I ended up modifying the original ashx handler in the "<a href="https://code.google.com/p/fullcalendar-asp-net/" rel="nofollow">fullcalendar-asp-net</a>" project. Instead of adding events to a string in a foreach loop, I created an event list and converted it to Json string with this code.</p> <pre><code>System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string sJSON = oSerializer.Serialize(tasksList); context.Response.Write(sJSON); </code></pre> <p>The full ashx code is like this.</p> <pre><code>/// &lt;summary&gt; /// Summary description for JsonResponse /// &lt;/summary&gt; public class JsonResponse : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //CONVERT FROM UTC TIMESTAMP TO LOCAL DATETIME DateTime start = ConvertFromTimeStamp(long.Parse(context.Request.QueryString["start"])); DateTime end = ConvertFromTimeStamp(long.Parse(context.Request.QueryString["end"])); List&lt;int&gt; idList = new List&lt;int&gt;(); List&lt;ImproperCalendarEvent&gt; tasksList = new List&lt;ImproperCalendarEvent&gt;(); //GENERATE JSON SERIALIZABLE EVENTS foreach (CalendarEvent cevent in EventDAO.getEvents(start, end)) { tasksList.Add(new ImproperCalendarEvent { id = cevent.id, title = cevent.title, start = ConvertToTimestamp(Convert.ToDateTime(cevent.start).ToUniversalTime()).ToString(), end = ConvertToTimestamp(Convert.ToDateTime(cevent.end).ToUniversalTime()).ToString(), description = cevent.description, allDay = cevent.allDay, } ); idList.Add(cevent.id); } context.Session["idList"] = idList; //SERIALIZE EVENTS TO STRING System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string sJSON = oSerializer.Serialize(tasksList); //WRITE JSON TO RESPONSE OBJECT context.Response.Write(sJSON); } /// &lt;summary&gt; /// Converts a UTC transformed timestamp into a local datetime /// &lt;/summary&gt; /// &lt;param name="timestamp"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; private DateTime ConvertFromTimeStamp(long timestamp) { long ticks = (timestamp * 10000000) + 621355968000000000; return new DateTime(ticks, DateTimeKind.Utc).ToLocalTime(); } private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); private static long ConvertToTimestamp(DateTime value) { TimeSpan elapsedTime = value - Epoch; return (long)elapsedTime.TotalSeconds; } public bool IsReusable { get { return false; } } } </code></pre> <p>When I asked this question, I was using a web method instead of that handler, so my js code to call the calendar was different than it should be. Now, I am using exactly the same method which was explained in the fullcalendar offical documentation. Like;</p> <pre><code>$('#calendar').fullCalendar({ events: '/myfeed.php', }); // for me, that is "JsonResponse.ashx" </code></pre> <p>Now it works with the latest version of all scripts which I mentioned at the question. Jquery 1.10.2, Jquery-UI 1.10.3 and fullcalendar 1.6.4. And it works perfectly!</p> <p>I hope that others who had trouble figuring out that issue won't suffer as I did :)</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload