Reputation: 11
//My web-service method WebService1.asmx
[WebMethod]
[ScriptMethod]
public string GetAllEvents()
{
var list = new List<string>();
list.Add("[{\"id\":\"36\"title\":\"Birthday party\",\"start\":\"2013-09-18\",\"end\":\"2013-09-18\",\"allDay\":false}]");
JavaScriptSerializer jss = new JavaScriptSerializer();
string strJSON = jss.Serialize(list.ToArray());
return strJSON;
}
//My jQuery snippet
$("#fullcalendar").fullCalendar({
eventSources:
[
{
url: "http://localhost:49322/WebService1.asmx/GetAllEvents",
type: 'POST',
dataType: "json",
contentType: "application/json; charset=utf-8",
}
]
});
Upvotes: 0
Views: 357
Reputation: 35353
You are on the wrong track.
It should be something like this:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Event> GetAllEvents()
{
List<Event> events = .......
..fill the list....
return evetns;
}
public class Event
{
public int id { get; set; }
public string title { get; set; }
public string start { get; set; }
public string end { get; set; }
public bool allDay { get; set; }
}
Upvotes: 2