p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional C#, 2nd and 3rd Editions (http://p2p.wrox.com/forumdisplay.php?f=44)
-   -   Lesson on Event Calendar - Chapter 14 (http://p2p.wrox.com/showthread.php?t=7811)

Mike Smith January 2nd, 2004 08:44 PM

Lesson on Event Calendar - Chapter 14
I am working through Chapter 14 of "Professional C# Second Edition". This is a lesson on an Event Booking application.

I have entered all the code through to page 782 and the Calendar works properly except the back color for the calendar squares do not show as red when booked.

I have gone in the Events Table and I can see that the bookings are showing there correctly. There is also a getFreeDate feature that prevents the cursor from clicking on a previously booked square on the Calendar. This feature works correctly.

I have tried changing the background color from "red" to "green" and this makes no difference.

The code that develops the red backcolor is shown below. If anyone has any suggestions, I would be pleased to hear from you.

Mike Smith
protected void calendar_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
if (eventTable.Rows.Count > 0)
    System.DateTime testDate;
    foreach (System.Data.DataRow testRow in eventTable.Rows)
    testDate = (System.DateTime)testRow["EventDate"];
    if (testDate.Date == e.Day.Date)
     e.Cell.BackColor = Color.Red;

kwilder January 29th, 2004 11:58 AM

I got the same results... apparently, the calendar_DayRender event isn't even firing. If you get an answer, I would be interested in hearing the resolution

kwilder January 29th, 2004 12:12 PM

I don't know why the 'DayRender' event isn't firing automatically, but I did find a way to get the event to fire. In the <asp:Calendar... object declaration, include the following...


this causes the DayRender event to fire.

Jim-e February 4th, 2004 04:13 AM

Iam having a similar problem with this same code. It is showing up in my case as an unhandled exception: Here are the details

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

private System.DateTime getFreeDate(System.DateTime trialDate)
if (eventTable.Rows.Count > 0) <--- error identified here....
System.DateTime testDate;


kekohchaa April 6th, 2004 02:39 AM

Is there any sample of the Event Booking Application in vb.net? or asp.net?

Jim-e April 6th, 2004 03:00 PM

For what it's worth I had some problems with the ASP Project in Chapter 14 also. After wasting a lot of time trying to debug and find the problem I finally was able to communicate with the author who sent me the latest version of the code. It works as advertised in this version. It appears he didn't upload the working version.

I have posted the version the author sent to me. It's on my website at "WebTutor.cc" Follow the download link to the C# download page. It is a self-extracting zip file.

Hope this helps.



Jim-e April 6th, 2004 03:03 PM

You might take a look at an update I just posted on this issue.


All times are GMT -4. The time now is 04:00 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.