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

Define URL for Event

Asked by Bobby
5 years ago.

I am new to DayPilot, but after two days I have been able to move along quite well. I am stuck at the moment trying to define a URL behind the event.

Thanks in advance,

  • Bobby
Answer posted by Dan Letecky [DayPilot]
5 years ago.

By default there is no URL associated with the event.

You should handle the EventClick event and define the required action. For redirecting it to a specified url you can use something like this:

          <%= Html.DayPilotMonth("dp", new DayPilotMonthConfig { 
                BackendUrl = ResolveUrl("~/Month/Backend"),
                
                EventClickHandling = EventClickHandlingType.JavaScript,
                EventClickJavaScript = "document.location.href = 'MyUrl?id=' + e.value()"
        })%>

Comment posted by Bobby
5 years ago.

Dan, I truly appreciate your patience, but I guess I'm not savvy enough with MVC just yet...

First, EventClickHandlingType "The name 'EventClickHandlingType' does not exist in the current context."

Second, My current thought is that I will have multiple events on the same day (I probably need to do better about describing the app) and I want different links per event. I think I want to load the link along with the event description and such.

Maybe this is not the schedule widget I need, but I do like it so far.

Thanks again,

  • Bobby
Answer posted by Dan Letecky [DayPilot]
5 years ago.

> First, EventClickHandlingType "The name 'EventClickHandlingType' does not exist in the current context."

Try to add the namespace:

<%= Html.DayPilotMonth("dp", new DayPilotMonthConfig { 
  BackendUrl = ResolveUrl("~/Month/Backend"),
                
  EventClickHandling = DayPilot.Web.Mvc.Events.Month.EventClickHandlingType.JavaScript,
  EventClickJavaScript = "document.location.href = 'MyUrl?id=' + e.value()"
})%>

You can also add it to the page header:

<%@ Import Namespace="DayPilot.Web.Mvc.Events.Month" %>

> Second, My current thought is that I will have multiple events on the same day (I probably need to do better about describing the app) and I want different links per event. I think I want to load the link along with the event description and such.

You can access the event properties using the e object (see also http://api.daypilot.org/daypilot-event-class/): e.value(), e.text(), e.start()....

With the latest version (1.3 SP1) you can also use a server-side Redirect() method:

View:
<%= Html.DayPilotMonth("dp", new DayPilotMonthConfig { 
  BackendUrl = ResolveUrl("~/Month/Backend"),
                
  EventClickHandling = DayPilot.Web.Mvc.Events.Month.EventClickHandlingType.CallBack
})%>
Controller (Dpm class):
protected override void OnEventClick(EventClickArgs e)
{
  Redirect("~/Dialog/Edit?id=" + e.Id);
}

See also:
http://mvc.daypilot.org/daypilot-lite-for-asp-net-mvc-1-3-sp1/

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