Моя маленькая тестовая программа, которую я получил из официальной книги MCTS EXAM 70-562, не запускает события.Я следил за компьютерной логикой в режиме отладки, и она даже не входила в мои события, хотя у меня все настроено для их обработки.Таким образом, большой вопрос в том, что я Я делаю неправильно?
**CODE BEHIND FILE:**
public partial class Calendar : System.Web.UI.Page
{
Hashtable _scheduleData;
protected void Page_Load(object sender, EventArgs e)
{
_scheduleData = GetSchedule();
Calendar1.Caption = "Personal Schedule";
Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;
Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;
Calendar1.TitleFormat = TitleFormat.MonthYear;
Calendar1.ShowGridLines = true;
Calendar1.DayStyle.HorizontalAlign = HorizontalAlign.Left;
Calendar1.DayStyle.VerticalAlign = VerticalAlign.Top;
Calendar1.DayStyle.Height = new Unit(75);
Calendar1.DayStyle.Width = new Unit(100);
Calendar1.OtherMonthDayStyle.BackColor = System.Drawing.Color.Cornsilk;
Calendar1.TodaysDate = new DateTime(2009, 2, 1);
Calendar1.VisibleDate = Calendar1.TodaysDate;
}
private Hashtable GetSchedule()
{
Hashtable schedule = new Hashtable();
schedule["2/9/2009"] = "Vactican Day";
schedule["2/18/2009"]="Budget planning meeting @ 3:00pm";
schedule["2/24/2009"]="Dinner plans with friends @ 7:00pm";
schedule["2/27/2009"]="Travel Day";
schedule["3/5/2009"]="Conf call @ 1:00pm";
schedule["3/10/2009"]="Meet with art director for lunch";
schedule["3/27/2009"]="Vacation Day";
return schedule;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
LabelAction.Text = "Selection changed to: " + Calendar1.SelectedDate.ToShortDateString();
}
protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
LabelAction.Text = "Month changed to : " + e.NewDate.ToShortDateString();
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (_scheduleData[e.Day.Date.ToShortDateString()] != null)
{
//Literal lit = new Literal();
lit.Text = "<br />";
e.Cell.Controls.Add(lit);
//Label lbl = new Label ();
lbl.Text = (string)_scheduleData[e.Day.Date.ToShortDateString()];
lbl.Font.Size=new FontUnit (FontSize.Small);
e.Cell.Controls.Add(lbl);
}
}
}
**ASPX CODE:**
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar.aspx.cs" Inherits="Calendar" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 350px">
<br />
<asp:Label ID="LabelAction" runat="server" Text=" "></asp:Label>
<br />
<asp:Literal ID="lit" runat="server"></asp:Literal>
<br />
<asp:Label ID="lbl" runat="server" Text=" "></asp:Label>
<br />
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged"
OnVisibleMonthChanged="Calendar1_VisibleMonthChanged"
OnDayRender="Calendar1_DayRender" SelectionMode="DayWeekMonth"> </asp:Calendar>
<br />
<asp:Label ID="Label1" runat="server" Text=" "></asp:Label>
<br />
</div>
</form>
</body>
</html>