0

我一直在做一个项目,但遇到了一个问题,即我可以使用 asp.net 日历控件选择第一个和最后一个日期,但我希望使用日历扩展器来完成

如下所示的代码用于日历控制..请为我提供所需修改的日历扩展器的解决方案........

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
   {
    Calendar1.SelectionMode = CalendarSelectionMode.DayWeek;
    //ArrayList selectedDates = new ArrayList();
    string s = Calendar1.SelectedDate.ToShortDateString();
    DateTime today = DateTime.Parse(s);
    DateTime firstDay = today.AddDays(-(double)(today.DayOfWeek));
    DateTime lastDay = today.AddDays(6 - (double)(today.DayOfWeek));
    for (int loop = 0; loop < 7; loop++)
        Calendar1.SelectedDates.Add(firstDay.AddDays(loop));
    lblStartOfWeek.Text = firstDay.ToLongDateString();
    lblEndOfWeek.Text = lastDay.ToLongDateString();
    lblStartOfWeek.Visible = true;
    lblEndOfWeek.Visible = true;
    checkLessonPlan();
   }
4

1 回答 1

0
 protected void Calendar1_ontextchanged(object sender, EventArgs e)
{

    string numberofdays=   Convert.ToDateTime(this.TextBox1.Text).DayOfWeek.ToString("d");
    DateTime select = Convert.ToDateTime(TextBox1.Text);
    lblStartOfWeek.Text = select.AddDays(-Convert.ToInt32(numberofdays)).ToString("dd MMMM yyyy");
    lblEndOfWeek.Text = select.AddDays(6-Convert.ToInt32(numberofdays)).ToString("dd MMMM yyyy");


}
于 2013-07-09T06:21:10.657 回答