Currently, I am in the process of integrating Daypilot lite calendar into my project. Progress has been decent so far, but I have encountered a small obstacle.
The issue arises when attempting to create a new event on the calendar - I am unable to pass any information other than the start and end times to the daypilot modal.
While working on this, I encountered a JavaScript runtime error: 'team' is undefined.
The snippet above highlights the error message that is causing trouble for me. Below is the code segment from my aspx page:
<h1>Welcome <asp:Label ID="lblTeam" runat="server"></asp:Label></h1>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="0">Select a pitch</asp:ListItem>
</asp:DropDownList>
<DayPilot:DayPilotCalendar
ID="DayPilotCalendar1"
runat="server"
DataStartField="sess_start"
ShowEventStartEnd="true"
DataEndField="sess_end"
DataTextField="team"
DataIdField="BookingId"
ClientObjectName="dpc1"
TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="timeRangeSelected(start, end, team, pitch)"
OnCommand="DayPilotCalendar1_Command"
NonBusinessBackColor="Black"
HeightSpec="BusinessHoursNoScroll"
BusinessEndsHour="20"
OnEventMove="DayPilotCalendar1_EventMove"
EventMoveHandling="CallBack"
/>
In order to send data to the modal using JavaScript, here's the code block I used:
function timeRangeSelected(start, end, team, pitch) {
team = document.getElementById('<%= lblTeam.ClientID %>').innerText;
var pitchSel = document.getElementById('<%= DropDownList1.ClientID %>');
pitch = pitchSel.options[pitchSel.selectedIndex].value;
var modal = new DayPilot.Modal();
modal.top = 60;
modal.width = 300;
modal.opacity = 70;
modal.border = "10px solid #d0d0d0";
modal.closed = function () {
if (this.result == "OK") {
dpc1.commandCallBack('refresh');
}
dpc1.clearSelection();
};
modal.showUrl("New.aspx?start=" + start.toStringSortable() + "&end=" + end.toStringSortable() + "&r=" + team + "&pitch=" + pitch);
}
At this stage, I aim to pass additional information besides just the start and end times to the modal window. Since there seems to be some confusion on my end, any assistance or guidance provided would be highly valued.