后台代码
public static string userID = System.Web.HttpContext.Current.Request.QueryString["UserID"].ToString();
//public static string userID = "B222EF78-D0E6-4EF5-991B-F96800E56030";
[System.Web.Services.WebMethod]
public static int addEvent(ImproperCalendarEvent improperEvent)
{
CalendarEvent cevent = new CalendarEvent()
{
userid = userID,
title = improperEvent.title,
description = improperEvent.description,
start =System.DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
end = System.DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
}; if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
{
int key = EventDAO.addevent(cevent); List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"]; if (idList != null)
{
idList.Add(key);
} return key; } return -1; } private static bool CheckAlphaNumeric(string str)
{ if (string.IsNullOrEmpty(str))
return false;
else
return true;
}js
$(document).ready(function () {
$('#updatedialog').dialog({
autoOpen: false,
width: 570,
buttons: {
"更新": function () {
var eventToUpdate = {
id: currentUpdateEvent.id,
title: $("#eventName").val(),
description: $("#eventDesc").val()
}; if (checkForSpecialChars(eventToUpdate.title) || checkForSpecialChars(eventToUpdate.description)) {
alert("请正确填写主题,内容.");
}
else {
PageMethods.UpdateEvent(eventToUpdate, updateSuccess);
$(this).dialog("close"); currentUpdateEvent.title = $("#eventName").val();
currentUpdateEvent.description = $("#eventDesc").val();
$('#calendar').fullCalendar('updateEvent', currentUpdateEvent);
} },
"删除": function () { if (confirm("确定要删除工作日志吗")) { PageMethods.deleteEvent($("#eventId").val(), deleteSuccess);
$(this).dialog("close");
$('#calendar').fullCalendar('removeEvents', $("#eventId").val());
} } }
}); $('#addDialog').dialog({
autoOpen: false,
width: 570,
buttons: {
"添加": function () {
var eventToAdd = {
// // id: 1,
// userid: '64238E8E-C594-4A93-A242-5812F78E81DC',
title: $("#addEventName").val(),
description: $("#addEventDesc").val(),
start: addStartDate.format("dd-MM-yyyy hh:mm:ss tt"),
end: addEndDate.format("dd-MM-yyyy hh:mm:ss tt")
};
if (checkForSpecialChars(eventToAdd.title) || checkForSpecialChars(eventToAdd.description)) {
alert("请正确填写主题,内容.");
}
else {
PageMethods.addEvent(eventToAdd, addSuccess);
$(this).dialog("close");
} } }
}); var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
dayNames: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
today: ["今天"],
firstDay: 1,
buttonText: {
today: '今天',
month: '月',
week: '周',
day: '日',
prev: '上一月',
next: '下一月'
},
eventClick: updateEvent,
selectable: true,
selectHelper: true,
select: selectDate,
editable: true,
events: "JsonResponse.ashx?userID="+ uid, eventDrop: eventDropped,
eventResize: eventResized,
eventRender: function (event, element) {
element.qtip({
content: event.description,
position: { corner: { tooltip: 'bottomLeft', target: 'topRight'} },
style: {
border: {
width: 1,
radius: 3,
color: '#2779AA' },
padding: 10,
textAlign: 'center',
tip: true,
name: 'cream'
} });
} });});每次弹出对话框插入数据时,id都为以前传入的id而非当前id,在后台设置断点无法进入但会直接跳转到其中调用的addevent插入数据的方法中
public static string userID = System.Web.HttpContext.Current.Request.QueryString["UserID"].ToString();
//public static string userID = "B222EF78-D0E6-4EF5-991B-F96800E56030";
[System.Web.Services.WebMethod]
public static int addEvent(ImproperCalendarEvent improperEvent)
{
CalendarEvent cevent = new CalendarEvent()
{
userid = userID,
title = improperEvent.title,
description = improperEvent.description,
start =System.DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
end = System.DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
}; if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
{
int key = EventDAO.addevent(cevent); List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"]; if (idList != null)
{
idList.Add(key);
} return key; } return -1; } private static bool CheckAlphaNumeric(string str)
{ if (string.IsNullOrEmpty(str))
return false;
else
return true;
}js
$(document).ready(function () {
$('#updatedialog').dialog({
autoOpen: false,
width: 570,
buttons: {
"更新": function () {
var eventToUpdate = {
id: currentUpdateEvent.id,
title: $("#eventName").val(),
description: $("#eventDesc").val()
}; if (checkForSpecialChars(eventToUpdate.title) || checkForSpecialChars(eventToUpdate.description)) {
alert("请正确填写主题,内容.");
}
else {
PageMethods.UpdateEvent(eventToUpdate, updateSuccess);
$(this).dialog("close"); currentUpdateEvent.title = $("#eventName").val();
currentUpdateEvent.description = $("#eventDesc").val();
$('#calendar').fullCalendar('updateEvent', currentUpdateEvent);
} },
"删除": function () { if (confirm("确定要删除工作日志吗")) { PageMethods.deleteEvent($("#eventId").val(), deleteSuccess);
$(this).dialog("close");
$('#calendar').fullCalendar('removeEvents', $("#eventId").val());
} } }
}); $('#addDialog').dialog({
autoOpen: false,
width: 570,
buttons: {
"添加": function () {
var eventToAdd = {
// // id: 1,
// userid: '64238E8E-C594-4A93-A242-5812F78E81DC',
title: $("#addEventName").val(),
description: $("#addEventDesc").val(),
start: addStartDate.format("dd-MM-yyyy hh:mm:ss tt"),
end: addEndDate.format("dd-MM-yyyy hh:mm:ss tt")
};
if (checkForSpecialChars(eventToAdd.title) || checkForSpecialChars(eventToAdd.description)) {
alert("请正确填写主题,内容.");
}
else {
PageMethods.addEvent(eventToAdd, addSuccess);
$(this).dialog("close");
} } }
}); var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
dayNames: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
today: ["今天"],
firstDay: 1,
buttonText: {
today: '今天',
month: '月',
week: '周',
day: '日',
prev: '上一月',
next: '下一月'
},
eventClick: updateEvent,
selectable: true,
selectHelper: true,
select: selectDate,
editable: true,
events: "JsonResponse.ashx?userID="+ uid, eventDrop: eventDropped,
eventResize: eventResized,
eventRender: function (event, element) {
element.qtip({
content: event.description,
position: { corner: { tooltip: 'bottomLeft', target: 'topRight'} },
style: {
border: {
width: 1,
radius: 3,
color: '#2779AA' },
padding: 10,
textAlign: 'center',
tip: true,
name: 'cream'
} });
} });});每次弹出对话框插入数据时,id都为以前传入的id而非当前id,在后台设置断点无法进入但会直接跳转到其中调用的addevent插入数据的方法中
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货