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

Dynamically adding a Calendar Control Blues

Asked by Redd
16 years ago.

I was attempting the solution offered in this article:

http://forums.daypilot.org/Topic.aspx/118/how_to_create_dynamically_the_calendar

In addition, I wanted to register some of the events. For example:

DayPilotCalendar cal = new DayPilotCalendar();
cal.BeforeEventRender += new DayPilot.Web.Ui.Events.BeforeEventRenderEventHandler(DayPilotCalendar_BeforeEventRender);

Then, I attempted to bind the calendar to a datasource, ie:

cal.DataSource = someList; // Generic list of applicable data objects
cal.DataBind();

I've tried creating the calendars and binding them in Page_Load (inside and out of the IsPostback check) and Page_Init. I also tried by overriding CreateChildControls.

No matter how I try, however, I cannot get the calendars to actually bind to anything! I get only empty calendars that are otherwise properly rendered. When I put a break point in the method that binds the calendars, it does actually stop, but nothing gets rendered. When I put a break point inside the BeforeEventRender method, however, it NEVER stops!

Also, if I add handlers for DataBinding and Databound and add breakpoints there, the code does stop.

Lastly, on my page I have the following control:

<asp:Table ID="tblCalendar" runat="server">
</asp:Table>

During the calendar creation, I create a new TableRow:

TableRow row = new TableRow();
tblCalendar.Rows.Add(row);

Then, I add the calendars like this:

TableCell cell = new TableCell();
cell.Controls.Add(cal);
row.Cells.Add(cell);

Note: these problems do not happen when I do not attempt to dynamically add the calendars at runtime.

Is there something that I am missing? I can't think of what I could be missing here. Any insights would be great.

Thanks!

Comment posted by Redd
16 years ago.
FYI if you are having the same problem... I found my problem. In my eternal idiocy, I forgot to set the StartDate and Days property, which meant the calendar always had the same original date, and thus never rendered anything for any dates other than the original. In addition, the bubble events do not seem to work if you use the following doc type: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > Thus, until a build is put out, make sure you use this doc type, since this one certainly allows the bubbles to work properly: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> I spent a couple of days trying to figure out why the bubble RenderContent event could be stepped through but nothing would show up. Changing the doc type worked for me in this case. If somebody has a more definitive answer for why the above worked, I'd like to hear it! Thanks
Comment posted by Dan Letecky
16 years ago.
Thanks for posting the solution!

DayPilotBubble was not fully tested with other doctypes - sorry for the troubles. I hope to get such issues fixed in DayPilot Pro 4.5 (it will be a clean-up release).
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.