ASP.Net的WebForms,jQuery的日历和放大器; JSON [英] ASP.Net WebForms, jQuery Calendar & json
问题描述
我有一个web表单(CSS)页面内一个jQuery的日历。我的理解JSON符号,它使用键值对的pretty简单。我的日历有可喂入JSON事件参数。这就是。
I have a jQuery calendar inside a webForms (ASPX) page. I understand json notation, it's pretty simple using key value pairs. My calendar has an event parameter that can be fed json. Here it is.
请原谅我的术语
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1),
backgroundColor: "#f56954",
borderColor: "#f56954"
},
{
title: 'Long Event',
start: new Date(y, m, d - 5),
end: new Date(y, m, d - 2),
backgroundColor: "#f39c12",
borderColor: "#f39c12"
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false,
backgroundColor: "#0073b7",
borderColor: "#0073b7"
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false,
backgroundColor: "#00c0ef",
borderColor: "#00c0ef"
},
],
在这一点上,我不希望用户与网页互动。我只关心这个填充jQuery的JSON得到填充了一个标题,从我的.NET对象数据源开始日期和结束日期。没什么特别的,我不介意被显示在前端JSON的信息。这个程序是登录之后,以便没有网页都是面向公众的。
At this point I do not want the user to interact with the page. I am only concerned with populating this jQuery json to get populated with a title, start date and end date from my a .Net Object Data Source. Nothing fancy, I don't mind the information being displayed as json on the front end. This app is behind a login so none of the pages are public facing.
我从来没有使用SQL Server来填充JSON数据。我已阅读,看起来像解决方案更多信息的地方是越来越传递到前端,然后坚持到后端的情况下线程数。
I have never used SQL Server to populate the json data. I have read a few threads that seem like the solutions are more for cases where information is getting passed to the front end and then persisted to the backend.
我发现这个线程这askes同样的问题,但目前还没有答案。
<一href=\"http://stackoverflow.com/questions/16177470/jquery-week-calendar-reading-json-data-asp-net\">jquery-week-calendar-asp.net
I have found this thread which askes the same question, but there are no answers. jquery-week-calendar-asp.net
任何人都可以引导我在正确的方向。我摸索试图找到工具来完成这件事的良方。
Can anyone steer me in the right direction. I'm fumbling trying to find the right recipe of tools to get this done.
推荐答案
您需要调用通过AJAX在服务器上的方法。这个方法应该返回JSON,像这样:
You'll need to call a method on the server via AJAX. This method should return JSON, like so:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Event> GetEvents()
{
// return someDbQueryToRetrieveYourEvents().ToList();
}
修改 - 添加日历插件特定的AJAX调用
EDIT - added calendar plugin specific AJAX call
阿贾克斯可能是这样的:
The AJAX might look like this:
$(document).ready(function() {
$('#calendar').weekCalendar({
data: function(start, end, callback) {
$.getJSON("calendarevents.json", {
start: start.getTime(),
end: end.getTime()
}, function(result) {
callback(result);
});
}
});
});
这是否帮助?
这篇关于ASP.Net的WebForms,jQuery的日历和放大器; JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!