在日历扩展程序中添加天数
我一直在研究一个项目,并且遇到了一个问题,即,我能够使用asp.net日历控件选择第一个和最后一个日期,但我希望使用日历程序" title="扩展程序">扩展程序在日历扩展程序中添加天数
如下所示的代码是用于控制压延..please我提供所需修改..............
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();
}
回答:
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");
}
以上是 在日历扩展程序中添加天数 的全部内容, 来源链接: utcz.com/qa/265280.html