问题描述
我一直在试图通过添加一个ASHX页面调用使用下列code一些事件的fullCalendar。
I have been trying to add some events to the fullCalendar using a call to a ASHX page using the following code.
页脚本:
<script type="text/javascript">
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today', center: 'title', right: 'month, agendaWeek,agendaDay'
},
events: 'FullCalendarEvents.ashx'
})
});
</script>
C#code:
c# code:
public class EventsData
{
public int id { get; set; }
public string title { get; set; }
public string start { get; set; }
public string end { get; set; }
public string url { get; set; }
public int accountId { get; set; }
}
public class FullCalendarEvents : IHttpHandler
{
private static List<EventsData> testEventsData = new List<EventsData>
{
new EventsData {accountId = 0, title = "test 1", start = DateTime.Now.ToString("yyyy-MM-dd"), id=0},
new EventsData{ accountId = 1, title="test 2", start = DateTime.Now.AddHours(2).ToString("yyyy-MM-dd"), id=2}
};
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json.";
context.Response.Write(GetEventData());
}
private string GetEventData()
{
List<EventsData> ed = testEventsData;
StringBuilder sb = new StringBuilder();
sb.Append("[");
foreach (var data in ed)
{
sb.Append("{");
sb.Append(string.Format("id: {0},", data.id));
sb.Append(string.Format("title:'{0}',", data.title));
sb.Append(string.Format("start: '{0}',", data.start));
sb.Append("allDay: false");
sb.Append("},");
}
sb.Remove(sb.Length - 1, 1);
sb.Append("]");
return sb.ToString();
}
}
该ASHX页面被调用和returnd以下数据:
The ASHX page gets called and returnd the following data:
[{ID:0,标题:测试1,启动:'2010-06-07',allDay:假},{ID:2,标题:测试2,启动:2010-06- 07',allDay:假}]
到ASHX页面调用不显示任何结果,但如果我粘贴值直接返回到它正确显示的事件。我是我一直试图让这个code到一天现在的工作,我不明白为什么事件没有得到设置。
The call to the ASHX page does not display any results, but if I paste the values returned directly into the events it displays correctly. I am I have been trying to get this code to work for a day now and I can't see why the events are not getting set.
任何帮助或我如何能得到这个工作将是AP preciated建议。
Any help or advise on how I can get this to work would be appreciated.
史蒂夫
推荐答案
在任何情况下过这个问题绊倒。我尝试了上述所有的解决方案,但他们都不工作。
对我来说,这个问题是通过使用jQuery的旧版本解决。我从被列入fullcalendar包1.3.2版本1.5.2版本切换
In case anyone stumbles across this problem. I tried all of the above solutions, but none of them worked.For me, the problem was solved by using an older version of jquery. I switched from version 1.5.2 which was included in the fullcalendar package to version 1.3.2
这篇关于从asp.net页面ASHX事件FullCalendar不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!