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

Refresh Daypilot not working correctly

Asked by Manov
9 years ago.

Hi there !
I'm coming here cause i'm in trouble since a couple of hours !
My problem is : I have some checkboxs who can hide or not some event in my daypilot calendar. At the moment, when I check a box, my item is not refreshed in the daypilot, but when I put a link who use my javascript function to refresh. It works ! So now i would like to do the same without a click on the link. When i change the box, i would like to call my js function to do the same... but it doesn't works !

Here is my link + checkboxs in my repeater :

<a href="javascript:checkedChanged();">refresh</a>
<asp:ScriptManager ID="SM1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="repeaterAct" runat="server">
<HeaderTemplate>
<div style="font-weight: bold; top:10;">Affichage par activité</div>
</HeaderTemplate>
<ItemTemplate>
<div>
<asp:CheckBox ID="CBAct" runat="server" Checked="false" Text='<%# Eval("libelléActivité") %>' AutoPostBack="true" OnCheckedChanged="CBAct_CheckedChanged" />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

Here is my js :

function checkedChanged() {
//alert("checkedChanged");
dpc1.commandCallBack('refresh');
}

And this is my codeBehind :

protected void CBAct_CheckedChanged(object sender, EventArgs e)
{
DayPilotCalendar1.DataBind();
//DayPilotCalendar1.Update();
ScriptManager.RegisterStartupScript(this, GetType(), "refresh", "checkedChanged();", true);
}

So when i press my checkbox, my data is rebind. At this moment, if i click on my link refresh, my DayPilot is refreshing and all looks good ! What I don't understand is : my CBAct_CheckedChanged function launch my JS function correctly (when I put the alert, it's nicely triggered !), so why my DayPilot is not well refreshing when I changed my checkboxs ?

Thx for yours answers !!

Answer posted by Dan Letecky [DayPilot]
9 years ago.

I believe removing AutoPostBack="true" will fix your problem.

If you have both AutoPostBack="true" and OnCheckedChanged="CBAct_CheckedChanged" set the following happens on the checkbox change:

1. The client-side handler is fired (OnCheckedChanged).

  • If this handler opens an alert box the page will wait until the alert box is closed.
  • Calling .commandCallBack will not wait because the AJAX callback it starts is asynchronous (it doesn't block the js execution).

2. If fires the PostBack. The asynchronous AJAX callback that was started by .commandCallBack is cancelled.

Let me know if it didn't help.

Comment posted by Manov
9 years ago.

Hi Dan and thanks for your answer !

I understand well what you are saying and i'm pretty sure my problem is near of that... asynchronous against client side work.. but the problem is i have to got this AutoPostBack="true" otherwise my OnCheckedChanged is not triggered and i never enter in my c# code behind.

So when i delete the AutoPostBack="true", my program doesnt go in the CBAct_CheckedChanged function and i can't call my :
ScriptManager.RegisterStartupScript(this, GetType(), "refresh", "checkedChanged();", true);
Even if i pass throw, when i refresh, my page doesn't know i changed my checkbox.checked status (CBAct.Checked is always equal to false without AutoPostBack="true"). And this is really a problem ! :D How to conturn that ?

Thx for yours answers.

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