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

Server Side Event Handling in Daypilot Lite??

Asked by Anonymous
12 years ago.

I can not seem to get server side event handling to work, I am using the Lite version.

It will post back but not read the event Click code, I have tried adding the OnEventClick and nothing.

??

Comment posted by Anonymous
12 years ago.

nevermind...i got it

:)

Comment posted by Dan Letecky
12 years ago.
Great ;-)
Comment posted by shawty
12 years ago.
Hi can you elaborate on that please, i have same issue here....

Heres Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="DayPilot" namespace="DayPilot.Web.Ui" tagprefix="DayPilot" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<h3>Schedular component test</h3>

<DayPilot:DayPilotCalendar ID="DayPilotCalendar1"
runat="server"
BusinessBeginsHour="6"
BusinessEndsHour="15"
Days="4"
JavaScriptEventAction=""
JavaScriptFreeAction=""
oneventclick="DayPilotCalendar1_EventClick"
onfreetimeclick="DayPilotCalendar1_FreeTimeClick"
TimeFormat="Clock24Hours" />

<asp:Label ID="lblTest" runat="server" Text="Testing label"></asp:Label>

</div>
</form>
</body>
</html>

And here is the code behind file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void DayPilotCalendar1_EventClick(object sender, DayPilot.Web.Ui.EventClickEventArgs e)
{
lblTest.Text = e.Value;
}
protected void DayPilotCalendar1_FreeTimeClick(object sender, DayPilot.Web.Ui.FreeClickEventArgs e)
{
lblTest.Text = e.Start.ToString("s");
}
}

Nothing seems to fire, no post back or anything...

I'm using VS2008 wit .NET 3.5 as a website solution.

Events where handled, using the properties panel in the IDE, so no hard wired code to create the event. Nothing seems to happen, it doesn't even generate a postback.

If i fill in the Javascript handlers they get called, no problem.

It has me stumped.

:-)
Comment posted by shawty
12 years ago.
Have just read the notes in

http://forums.daypilot.org/Topic.aspx/8/event_handling

and still no joy :-(
Comment posted by shawty
12 years ago.
Heh... :-)

Ok, it appears i was being a pleb, iv'e sussed it....

I was changing the value of "EventClickHandling" when i should have been changing "FreeTimeClickHandling"

Lessons to be learned part 1 : Try changing everything... even if it don't seem relevent...

Sorry if i wasted anyones time...
Comment posted by Dan Letecky
12 years ago.
Hi shawty: Sorry for not responding in time and thanks for posting the solution!
Comment posted by coffmat
10 years ago.

I'm having the same problem, what is wrong with my code?

in default.aspx:

<form id="form1" runat="server">
<div>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="160" valign="top">
<asp:UpdatePanel ID="UpdatePanelNavigation" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Calendar ID="Calendar1" runat="server" CssClass="calendar" DayNameFormat="FirstTwoLetters">
<TodayDayStyle BorderColor="Red" BorderStyle="Solid" BorderWidth="1px"></TodayDayStyle>
<SelectedDayStyle BackColor="#FBE694" ForeColor="Black" CssClass="selected"></SelectedDayStyle>
<TitleStyle BackColor="White"></TitleStyle>
<OtherMonthDayStyle ForeColor="#ACA899"></OtherMonthDayStyle>
</asp:Calendar>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td width="20">
&nbsp;</td>
<td valign="top" width="100%">
<asp:UpdatePanel ID="UpdatePanelCalendar" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>

<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server"
DataTextField="name" DataValueField="id" TimeFormat="Clock12Hours" EventClickHandling="PostBack"
DataStartField="eventstart" DataEndField="eventend" Days="7" OnEventClick="DayPilotCalendar1_EventClick"
OnFreeTimeClick="DayPilotCalendar1_FreeTimeClick"
></DayPilot:DayPilotCalendar>

</ContentTemplate>

</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<asp:Label ID="Label1" runat="server" Text="Label1"></asp:Label>
</form>

below is from default.aspx.vb:

Protected Sub DayPilotCalendar1_FreeTimeClick(ByVal sender As Object, ByVal e As FreeClickEventArgs)
Label1.Text = "Time cell starting at " + e.Start & " clicked."
End Sub

Protected Sub DayPilotCalendar1_EventClick(ByVal sender As Object, ByVal e As EventClickEventArgs)
Label1.Text = "Event with ID " + e.Value & " clicked."
End Sub

Private Function dbGetEvents(ByVal start As DateTime, ByVal days As Integer) As DataTable
Dim da As New Data.SQLite.SQLiteDataAdapter("SELECT [id], [name], [eventstart], [eventend] FROM [event] WHERE NOT (([eventend] <= @start) OR ([eventstart] >= @end))", ConfigurationManager.ConnectionStrings("db").ConnectionString)
da.SelectCommand.Parameters.AddWithValue("start", start)
da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days))
Dim dt As New DataTable()
da.Fill(dt)
Return dt
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Request.Browser.Browser = "Firefox" Then
Response.Cache.SetNoStore()
End If

If Not IsPostBack Then
DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek()

' select full week in the Calendar control
Dim i As Integer
For i = 0 To 7 - 1 Step i + 1
Dim selected As DateTime = DayPilotCalendar1.StartDate.AddDays(i)
Calendar1.SelectedDates.Add(selected)
Next
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days)
DataBind()
End If

End Sub

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