I am currently utilizing asp.net C#.
Here is the code snippet I have:
CalendarInfo oInfo = new CalendarInfo { title = "Joe Bloggs", start = System.DateTime.Now.ToString("yyyy-MM-dd"), end = System.DateTime.Now.AddDays(3).ToString("yyyy-MM-dd") };
var ser = new JavaScriptSerializer();
JsonConvert.SerializeObject(oInfo);
hdCalContent.Value = JsonConvert.SerializeObject(oInfo);
ltCal.Text= JsonConvert.SerializeObject(oInfo);
However, on the client side, I need the data to be in the following format:
[
{
title: 'All Day Event',
start: '2016-06-01',
end: '2016-06-10'
},
{
title: 'Long Event',
start: '2016-06-07',
end: '2016-06-10'
}
];
The issue with my C# code is that it generates something like "title:"Joe Blog"
, which is causing it not to work correctly. Can you help me generate the JSON in the exact format required for the client side? Below is my current client side code:
JSON.parse($("[id$='hdCalContent']").val())`
I'm eagerly awaiting a solution.
Below is a static version of the code that is valid and working with jQuery FullCalendar:
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2016-06-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2016-06-01'
},
{
title: 'Long Event',
start: '2016-06-07',
end: '2016-06-10'
},
{
title: 'Birthday Party',
start: '2016-06-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2016-06-28'
}
]
});
In this case, the events will be fetched from the server side using C# code. I've implemented the code but it's not functioning as expected.