Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 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 September 16th, 2004, 01:29 PM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sarah-WCHM
Default CustomCalendar.cs problem - ch. 13

Hey all,

I'm having a problem with the custom calendar ... once I switch from the original calendar to the custom one, no calendar displays! This happens when I use the code included in the complete code download as well. I'm using the C# version of the book.

Any help would be appreciated--Code follows.

// CustomCalendar.cs
//

namespace WroxUnited
{
  using System;
  using System.ComponentModel;
  using System.Web.UI;
  using System.Collections;
  using System.Web.UI.WebControls;

  public class CustomCalendar : Control, INamingContainer
  {
    private Calendar calendar;
    public event EventHandler SelectionChanged;
    private Hashtable _dateList;

    public Hashtable DateList
    {
      get
      {
        return _dateList;
      }
      set
      {
        _dateList = value;
      }
    }

    public DateTime SelectedDate
    {
      get
      {
        return calendar.SelectedDate;
      }
    }

    protected override void CreateChildControls()
    {
      calendar.CssClass = "calendar";
      calendar.DayStyle.CssClass = "normaldate";
      calendar.OtherMonthDayStyle.CssClass = "othermonthdate";
      this.Controls.Add(calendar);
    }

    protected override void OnInit(EventArgs e)
    {
      base.OnInit(e);

      calendar = new Calendar();

      calendar.DayRender += new DayRenderEventHandler(this.EventCalendar_DayRender );
      calendar.SelectionChanged += new EventHandler(this.EventCalendar_SelectionChanged);
    }

    private void EventCalendar_DayRender(object sender, DayRenderEventArgs e)
    {
      if (_dateList != null)
      {
        if (_dateList[e.Day.Date] != null)
        {
          e.Cell.CssClass = "selecteddate";
          e.Day.IsSelectable = true;
        }
        else
        {
          e.Day.IsSelectable = false;
        }
      }
      else
      {
        e.Day.IsSelectable = false;
      }
    }

    private void EventCalendar_SelectionChanged(object sender, EventArgs e)
    {
      if (SelectionChanged != null)
      {
        SelectionChanged(this, e);
      }
    }
  }
}


// From Default.aspx

<%@ Register TagPrefix="WroxUnitedCalendar" Namespace="WroxUnited" Assembly="CustomCalendar" %>
.
.
.
<html>
.
.
.
  <form>
    .
    .
    .
<WROXUNITEDCALENDAR:CUSTOMCALENDAR id="EventCalendar" runat="server" OnSelectionChanged="EventCalendar_SelectionChanged " />

// From Default.aspx.cs

.
.
.
public WroxUnited.CustomCalendar EventCalendar;
.
.
.

    public void Page_Load(object sender, EventArgs e)
    {
.
.
.
 EventCalendar.DateList = (Hashtable)Cache["DateList"];
.
.
.
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
ch 13 - sketcher menu problem zamontgo BOOK: Ivor Horton's Beginning Visual C++ 2005 0 May 24th, 2008 10:11 PM
CH 13 - ASPNET Login failure sjbramer BOOK: Beginning VB.NET Databases 3 July 12th, 2006 01:08 PM
Ch. 13/14 creating own custom controls...problem.. Chimlim BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 August 10th, 2005 04:21 AM





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