I am trying to display events in the dhtmlx scheduler and pass the clicked event id to another registration form (view). I can get the event_id but I have no clue how to pass the event_id to controller action. My sample code is below:
<h2>Appointment Calendar</h2>
@using (Html.BeginForm())
{
<div class="scheduler_container" style='height: 600px;'>
@Html.Raw(Model.Render())
</div>
}
<script>
scheduler.attachEvent("onClick", function (id, e) {
console.log(id);
//call controller method
$.ajax({
type: "POST",
url: "/Home/Registration",
data: { EventId: id },
// data: {EventId:$('#event_id').val()},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
window.location.href = "Registration/" + id;
},
error: function (response) {
}
});
//window.location.href = "Registration/" + id;
return true;
});
</script>
controller:
public ActionResult Registration(int? EventId) <- the EventId is null here
{
var Event = db.Appointments.Where(s => s.Id.Equals(EventId)).FirstOrDefault();
...
return View();
}