クライアントによって Calender コントロールで日付が選択されるたびに、サーバー上の DateTime オブジェクトのリストに追加し、コントロールで選択されたすべての日付を強調表示します。ページの読み込み時にリストでインスタンス化された日付と、クライアントが最初に選択した日付を強調表示 (背景色を変更) できます。ただし、コントロールでさらに日付を選択すると、強調表示される日付が変更されます。これ以上強調しません。
選択時に選択した DateTime オブジェクトを実行時にリストに追加し、それぞれを Calendars の「選択した日付」プロパティに追加することで、新しい日付の選択時に SelectedDates プロパティをクリアするカレンダー コントロールの問題を回避できると考えていました。 . 日付リスト内のすべての日付をテキストボックスに出力してデバッグすると、リストがインスタンス化された日付と最新の選択がリストにのみ表示され、以前の選択には表示されません。私の質問と私が問題だと思うのは、実行時にクライアントからのアクションによってサーバー上のリストにデータが入力され、追加されることはありますか? VS2008 で C# .Net3.5 で ASP を使用しています。ありがとう
マイ コード System.Collections.Generic.List 日付;
protected void Page_Load(object sender, EventArgs e) {
this.dates = new List<DateTime>();
this.dates.Add(new DateTime(2009,12,2));
this.dates.Add(new DateTime(2009, 12, 3));
this.dates.Add(new DateTime(2009, 12, 16));
fillDates();
}
protected void AvailCalender_SelectionChanged(object sender, EventArgs e){
this.dates.Add(this.AvailCalender.SelectedDate);
foreach (DateTime date in this.dates)
{
this.AvailCalender.SelectedDates.Add(date);
this.displayText.Text = this.displayText.Text + date.ToShortDateString();
}
fillDates();
}
protected void fillDates()
{
foreach (DateTime dates in this.dates)
{
this.AvailCalender.SelectedDates.Add(dates);
}
this.AvailCalender.SelectedDayStyle.BackColor = System.Drawing.Color.Blue;
}