Hi, I'm trying to refresh the calendar from a Javescript function. The first time the page is loaded, the function fires as expected and the calendar is updated; after that initial working action, it will never update again. I've tried postback, callback, JavaScript, voodoo dolls, four leaf clovers, a threat of physical force, yet it won't work. Here's the entire javascript:
function editStaff() {
var modal = new DayPilot.Modal();
modal.top = 60;
modal.width = 300;
modal.height = 400;
modal.opacity = 0;
modal.border = "10px solid #d0d0d0";
modal.closed = function () {
if (this.result != "cancel") {
dpc1.commandCallBack("refresh");
}
};
var curText = document.getElementById("<%= hfStaffName.UniqueID %>").value;
if (curText.length > 0) {
var url = "staff/editstaff.aspx?staff=" + curText;
modal.showUrl(url);
}
}
<daypilot:daypilotcalendar id="DayPilotCalendar1" runat="server" ShowAllDayEventStartEnd="true"
AllDayEventBackColor="Gray"
AllDayEnd="DateTime"
CellBorderColor="#000000"
datastartfield="eventstart"
dataendfield="eventend"
datatextfield="ItemDesc"
datavaluefield="id"
datatagfields="color,name"
DataAllDayField="allday"
BusinessBeginsHour="8"
BusinessEndsHour="22"
ViewType="Resources"
DataColumnField="resource"
OnEventMove="DayPilotCalendar1_EventMove"
OnEventClick="DayPilotCalendar1_EventClick"
OnEventEdit="DayPilotCalendar1_EventEdit"
OnBeforeEventRender="DayPilotCalendar1_BeforeEventRender"
OnEventDelete="DayPilotCalendar1_EventDelete"
OnEventSelect="DayPilotCalendar1_EventSelect"
OnEventResize="DayPilotCalendar1_EventResize"
OnTimeRangeSelected="DayPilotCalendar1_TimeRangeSelected"
OnTimeRangeDoubleClick="DayPilotCalendar1_TimeRangeDoubleClick"
OnTimeRangeMenuClick="DayPilotCalendar1_TimeRangeMenuClick"
OnCommand="DayPilotCalendar1_Command"
OnBeforeCellRender="DayPilotCalendar1_BeforeCellRender"
OnBeforeTimeHeaderRender="DayPilotCalendar1_BeforeTimeHeaderRender"
OnEventMenuClick="DayPilotCalendar1_EventMenuClick"
EventMoveHandling="Callback"
TimeRangeSelectedHandling="Postback"
EventDeleteJavaScript="if (confirm('Do you really want to delete ' + e.text() + ' ?')) dpc1.eventDeleteCallBack(e);"
EventResizeHandling="CallBack"
EventClickHandling="Postback"
EventSelectHandling="Postback"
ClientObjectName="dpc1"
EventEditHandling="Callback"
EventDeleteHandling="Postback"
EventSelectColor="Blue"
HeightSpec="BusinessHoursNoScroll"
ContextMenuID="DayPilotMenu1"
Showalldayevents="false"
Useeventboxes="Always"
ShowToolTip="true"
EventDoubleClickHandling="PostBack"
EventDoubleClickJavaScript="alert(e.value());"
TimeRangeDoubleClickHandling="Postback"
TimeFormat="Clock12Hours"
ContextMenuSelectionID="DayPilotMenuSelection"
CssClassPrefix="calendar_silver_"
HourNameBackColor=""
BorderColor="#A0A0A0"
HourBorderColor="Black"
HourHalfBorderColor="Black"
EventBorderColor="#505050"
AllDayEventBorderColor="#ff0000"
EventArrangement="SideBySide"
CellDuration="15"
HeaderLevels="2"
HeaderDateFormat="dddd MMMM d,yyyy"
OnHeaderClick = "DayPilotCalendar1_HeaderClick1"
HeaderClickHandling="Postback"
></daypilot:daypilotcalendar>
Code behind:
Protected Sub DayPilotCalendar1_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
Dim sMsg As String = Nothing
Select Case e.Command
Case "previous"
DayPilotCalendar1.StartDate = DayPilotCalendar1.StartDate.AddDays(-1)
LoadEvents()
defineColumns()
DayPilotCalendar1.DataBind()
DayPilotCalendar1.Update(CallBackUpdateType.Full)
Exit Select
Case "next"
DayPilotCalendar1.StartDate = DayPilotCalendar1.StartDate.AddDays(1)
'lblCalHead.Text = DayPilotCalendar1.StartDate.ToString("MMMM yyyy")
LoadEvents()
defineColumns()
DayPilotCalendar1.DataBind()
DayPilotCalendar1.Update(CallBackUpdateType.Full)
Exit Sub
Case "today"
DayPilotCalendar1.StartDate = DateTime.Today
LoadEvents()
defineColumns()
DayPilotCalendar1.DataBind()
DayPilotCalendar1.Update(CallBackUpdateType.Full)
Exit Sub
Case "navigate"
Dim start As DateTime = CType(e.Data("start"), DateTime)
Dim [end] As DateTime = CType(e.Data("end"), DateTime)
DayPilotCalendar1.StartDate = start.AddDays(DayPilotCalendar1.Days - 1)
LoadEvents()
defineColumns()
DayPilotCalendar1.DataBind()
DayPilotCalendar1.Update(CallBackUpdateType.Full)
Exit Sub
Case "refresh"
LoadEvents()
defineColumns()
DayPilotCalendar1.DataBind()
DayPilotCalendar1.Update(CallBackUpdateType.Full)
Exit Sub
End Select
End Sub
I'm totally lost here and my client is really getting impatient. Any help you could give me would be most appreciated.