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

Changing DayPilot StartDate Causes Error

Asked by Chris
17 years ago.

Hi, I have been using the DayPilot Lite control in a project, where by the start date is dynamically set from a calendar control. Each time the user selects a new date within the calendar, the DayPilot control is automatically refreshed and data for the selected date is then bound to the control and displayed to the user. I have to say that this works perfectly.....

However, we have just purchased the DayPilot Pro control and i now find that i can't replicate this functionality, even by creating a new project with only a calendar control and the DayPilot control. I find that the first days displayed work correctly, but, when i change the StartDate and rebind the data, the click events stop working and then i get a javascript error saying "'undefined' is null or not an object"?

I have tried configuring the DayPilot control to use javascript, postback and callback for the click events but i still get the same error. Can anyone shed some light on this please?

Many thanks, Chris.

Comment posted by Dan Letecky
17 years ago.
> the DayPilot control is automatically refreshed

Do you refresh it using SelectionChanged event of System.Web.UI.WebControls.Calendar (PostBack)? I've tried to replicate the bug using a simple page that changes StartDate in the SelectionChanged event handler but it seems to be working fine.

Can you please send a sample page that reproduces the bug to daypilot @ annpoint.com? I will take a look at it.
Comment posted by Chris
17 years ago.

Hi Dan, thank you for your quick reply.

I have emailed a copy of my test project to you at the supplied address.

Yes, i have tried using the SelectionChanged event of the calendar control, as well as grabbing the value during the page pre render event but to no avail.

Comment posted by Chris
17 years ago.

Hi Dan,

Thank you very much again for helping me out with this and the supplied solution.

Best regards,

Chris.

Comment posted by Dan Letecky
17 years ago.
Just to explain the issue to other users:

The project was using Anthem.NET for AJAX functionality: Anthem:Calendar for date selection and DayPilot Pro placed inside Anthem:Panel. Anthem.NET is one of the early .NET AJAX libraries and the functionality is very similar to the ASP.NET AJAX (with regard to Anthem:Panel vs. UpdatePanel).

DayPilot Pro needs an initialization JavaScript to be executed after loading the HTML. The Anthem.NET callback updated the HTML but the initalization code was not executed.

I've made changes in DayPilot that allow calling the initalization JavaScript as a single function (it will be available in DayPilot Pro 3.7 SP3). This function could then be executed after Anthem callback using PostCallBackFunction property:

<anthem:Calendar ID="Calendar1" runat="server" EnableCallBack="true" EnableViewState="true" FirstDayOfWeek="Sunday" PostCallBackFunction="function() { dpc1 = dpc1_Init(); }">
</anthem:Calendar>
Comment posted by JFC
17 years ago.

Hello, is it possible to have a full code to update the selected date with callback only using anthem calendar ?

My code raise the event PostCallBackFunction before the SelectionChanged event so it is not working :

<%@ Page Language="C#" MasterPageFile="~/Sample.master" %>

<%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>
<%@ Register TagPrefix="anthem" Namespace="Anthem" Assembly="Anthem" %>

<script runat="server">

DateTime ldt;

protected void DayPilotCalendar1_Refresh(object sender, DayPilot.Web.Ui.Events.RefreshEventArgs e)
{
DayPilotCalendar1.StartDate = ldt; // e.StartDate;
DayPilotCalendar1.DataBind();
DayPilotCalendar1.Update();
}



protected void cal_SelectionChanged(object sender, EventArgs e)
{
ldt = cal.SelectedDate;
}
</script>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder" runat="server">
<script language='javascript'>

function Test()
{
var ldt= new Date(Date.UTC(74,11,24));
alert(ldt.toGMTString());
dpc1.refreshCallBack(ldt);
}

</script>
<h2>Example</h2>
<anthem:Calendar id="cal" runat="server"
TextDuringCallBack='<img src="tiny_red.gif" border=0 />'
PostCallBackFunction="Test()" OnSelectionChanged="cal_SelectionChanged">
</anthem:Calendar>
<DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" ClientObjectName="dpc1" OnRefresh="DayPilotCalendar1_Refresh">
</DayPilot:DayPilotCalendar>
</asp:Content>

Comment posted by JFC
17 years ago.

Solution:

PostCallBackFunction="Test" instead of PostCallBackFunction="Test()"

Comment posted by Dan Letecky
17 years ago.
JFC, Thanks for posting your solution!
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.