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

ViewState data out of sync after Calendar Command previous and next

Asked by Colin
13 years ago.

First off, great work, love the controls.

I've got a month view calendar with two links to move the calendar previous and next each month. It works great and my events show as expected.

when the next/previous links are click and the command event is handled on the server, I update an object in ViewState to hold detailed information about each event. Then when I mouse over an event (and I have the the bubble object in place) I render the event details. However, this only work on the first page load. After the month has been moved (either previous or next and the ViewState data has been updated) the event bubbling popup does not show the event details as expected.

Is there something I can do about this?

Also, when switching to the previous and next month, I'd like to update some text on the screen the show the current month and year. What is the best way to do this? If there a js method I can use that is fired when a request is complete? Or can I use an MS Ajax update Panel?

Thanks, Colin (If I can get these problems solved, you can expect a purchase of this control in the next day or two)

Comment posted by Dan Letecky
13 years ago.

Hi Colin, I'm glad that you like the controls.

1) ViewState

I assume you are using the CallBack mechanism (commandCallBack client-side function) to change the month. CallBack has a limited reach - it can only modify the control itself (and only its own ViewState). If you need to persist some state, you have the following options:

  • Pass the state manually with each callback request back and forth using Update(object) and clientState. This is quite a lot of work, however, and not very efficient.
  • Use Session object. I would try to avoid using Session if you don't use it already.
  • Switch to UpdatePanel and PostBack event handling and keep using ViewState.
  • I would recommend not persisting the event details this way and reading it from the DB instead each time the bubble content is requested. Is there anything you don't like about this approach? Don't be afraid of using the DB, usually it's a simple and fast query.

Another solution would be to pass full event details with the bubble request. I've considered adding this feature for some time but I can't promise any date.

2) Updating other page elements during CallBack

Using UpdatePanel is the easy way but slower as well. You can use AfterRenderJavaScript property to fire custom JavaScript code.

If you are using DayPilot Scheduler, you can show the current month and year in the upper-left corner using BeforeResHeaderRender (check the e.IsCorner property).

Comment posted by Colin
13 years ago.

Thanks for the reply Dan.

1) Yeah, I'll just make a DB call. Was trying to avoid it since I already had the requred data, but that's Ok.

2) Great! I've now implemented this:

<daypilot:DayPilotMonth id="dpViewMonth"
datastartfield="StartDate" dataendfield="EndDate"
datatextfield="Name" datavaluefield="ID"
datatagfields="name, id"
Days="7" ClientObjectName="dpm"
AfterRenderJavaScript="afterRender(data, isCallBack)"

function afterRender(data, isCallBack)
if (isCallBack)
var txtMonthName = document.getElementById("txtMonthName");
txtMonthName.innerHTML = dpm.monthNames[dpm.month-1] + " " + dpm.year;

Comment posted by Dan Letecky
13 years ago.

Thanks for posting your code, Colin!

Comment posted by Jakob
12 years ago.

I have tried this approach and the js callback gets called, but the data parameter is consistently null (and isCallback is false when I include that as a parameter).

The scheduler sits inside an updatepanel.


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