Wrox Programmer Forums
|
BOOK: Professional C#, 2nd and 3rd Editions
This is the forum to discuss the Wrox book Professional C#, 3rd Edition by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen; ISBN: 9780764557590
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C#, 2nd and 3rd Editions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2004, 08:44 PM
Registered User
 
Join Date: Dec 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;
         }
        }
}
}
 
Old January 29th, 2004, 11:58 AM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 29th, 2004, 12:12 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

OnDayRender="calendar_DayRender"

this causes the DayRender event to fire.

 
Old February 4th, 2004, 04:13 AM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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;


Jim
 
Old April 6th, 2004, 02:39 AM
Authorized User
 
Join Date: Apr 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kekohchaa
Default

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


 
Old April 6th, 2004, 03:00 PM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Jim
 
Old April 6th, 2004, 03:03 PM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Jim





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14 Calendar Control sajhak ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 12:11 PM
Chapter 14 Calendar webrobb BOOK: Beginning ASP.NET 1.0 7 August 28th, 2006 03:59 AM
Ch. 14 Calendar Modification Astalder BOOK: Beginning ASP.NET 1.0 6 December 1st, 2004 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.