search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to call a daypilot EventClickJavaScript on button click of ASP.NET WEBFORM - C#

Asked by Anonymous
2 years ago.

I have a DayPilotCalendar like below. Here I'm calling a function 'ask(e)' on the EventClickJavaScript . Clicking on the event will redirect to corresponding event edit page.

<DayPilot:DayPilotCalendar
ID="DayPilotCalendarDay"
runat="server"
ClientObjectName="dp_day"
DataEndField="end_time"
DataStartField="start_time"
DataTextField="type_of_class"
DataValueField="task_id"
DataRecurrenceField="recurrence"
Theme="timetable_simple"
ViewType="Day"
TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="create(start, end, resource);"
EventMoveHandling="CallBack"
EventResizeHandling="CallBack"
OnCommand="DayPilotCalendarDay_Command"
EventClickHandling="JavaScript"
EventClickJavaScript="ask(e)"
oneventmove="DayPilotCalendarDay_EventMove"
oneventresize="DayPilotCalendarDay_EventResize"
onbeforeeventrender="DayPilotCalendarDay_BeforeEventRender"
/>

function ask(e) {

// it's a normal event
if (!e.recurrent()) {
edit(e);
return;
}
// it's a recurrent event but it's an exception from the series
if (e.id() !== null) {
edit(e);
return;
}
var modal = new DayPilot.Modal();
modal.closed = function () {
if (this.result != "cancel") {
edit(e, this.result);
}
};
modal.showUrl("RecurrentEditMode.html");
}

function edit(e, mode) {
var url = "EditTask.aspx?q=1"
if (e.recurrentMasterId()) {
url += "&master=" + e.recurrentMasterId();
}
if (e.value() !== null) {
url += "&id=" + e.id();
}
if (mode == "this") {
url += "&start=" + e.start();
}
createModal().showUrl(url);
}

Now I want to call the same ask(e) from a, aspx button click event of code behind of asp.net. For that I have done like below. But when clicking on the button, the edit page of corresponding is not popping up. var e = new DayPilot.Event(data); seems throws exception.

<script type="text/javascript">
var data = {
id: "1203",
start: "2021-08-18T09:00:00",
end: "2021-08-18T13:00:00",
text: "Event 1"
};
function CallWhenButtonClicked() {
var e = new DayPilot.Event(data);
ask(e);
}
</script>

And one more doubt is how the system knows the values !e.recurrent()),e.recurrentMasterId(),e.value() from this data only?
Please help.

NB: I have a non recurrent task on database with start,end and id as given above.

Answer posted by Dan Letecky [DayPilot]
2 years ago.

Instead of trying to build the DayPilot.Event object, I recommend changing the ask() function signature so it would accept individual parameters that are available to the button click event handler.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.