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

FreeTimeClick and EventClick not executing

Asked by Seung
16 years ago.
Hello,

I am trying out DayPilot Lite Version (2.3)

In my aspx.
<DayPilot:DayPilotCalendar ID="testCalendar" runat="server"
DataStartField="Start" DataEndField="End" DataTextField="Text" DataValueField="Value"
/>
In Code-behind.
testCalendar.EventClickHandling = DayPilot.Web.Ui.UserActionHandling.PostBack;
testCalendar.FreetimeClickHandling = DayPilot.Web.Ui.UserActionHandling.PostBack;
testCalendar.FreeTimeClick += new DayPilot.Web.Ui.FreeClickDelegate(testCalendar_FreeTimeClick);
testCalendar.EventClick += new DayPilot.Web.Ui.EventClickDelegate(testCalendar_EventClick);

The click event handler
protected void testCalendar_FreeTimeClick(object sender, DayPilot.Web.Ui.FreeClickEventArgs e)
{
somet code to do...
}


I put a break point within the event handler, and nothing happens.

I even tried using the source code, and I saw this part.
DayPilotCalendar.cs
public void RaisePostBackEvent(string eventArgument)
{

if (eventArgument.StartsWith("PK:"))
{
string pk = eventArgument.Substring(3, eventArgument.Length - 3);
if (EventClick != null)
EventClick(this, new EventClickEventArgs(pk));
}
else if (eventArgument.StartsWith("TIME:"))
{
DateTime time = Convert.ToDateTime(eventArgument.Substring(5, eventArgument.Length - 5));
if (FreeTimeClick != null)
FreeTimeClick(this, new FreeClickEventArgs(time));
}
else
{
throw new ArgumentException("Bad argument passed from postback event.");
}
}
The FreeTimeClick is always null, even though I set the event handler on my code-behind.

I have no idea why this happens. Postback happens properly, but the FreTimeClick event does not happen somehow. The FreeTimeClick event property is always set to null.

Can someone help?
Comment posted by Dan Letecky
16 years ago.
I would guess you have the event handler assigning code inside if (!IsPostBack) {} block:
if (!IsPostBack) {
// ...
testCalendar.FreeTimeClick += new DayPilot.Web.Ui.FreeClickDelegate
(testCalendar_FreeTimeClick);
// ...
}
You can try moving the code outside of that block or put it into the .aspx file:
<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" 
...
OnEventClick="testCalendar_EventClick"
OnFreeTimeClick="testCalendar_FreeTimeClick">
</DayPilot:DayPilotCalendar>
Comment posted by Anonymous
16 years ago.
Wow, that worked!
I don't understand why the event handlers should be assigned outside of the IsPostBack block for DayPilot, but it worked.

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