【发布时间】:2015-05-14 10:45:43
【问题描述】:
我在使用 asp 日历时遇到了以下问题。
目前,我可以在 1 个月内的范围(我已设置)内选择多个日期。但是,如果我的范围在 2 个月内(跨月),我将无法获得正确的选定日期。
2个月内:
如果我的日历显示在第 1 个月,我仍然可以获取第 2 个月的日期,但可能在第 2 个月有重复的日期。
如果我的日历显示在第 2 个月,我只能获取第 2 个月的日期。
对上述问题有什么建议吗?先谢谢了~=)
protected void CalendarMain_DayRender(object sender, DayRenderEventArgs e)
{
DateTime minDate, maxDate;
if (!tbStartDate.Text.Equals("") && !tbEndDate.Text.Equals(""))
{
minDate = Convert.ToDateTime(tbStartDate.Text);
maxDate = Convert.ToDateTime(tbEndDate.Text);
if (e.Day.Date < minDate || e.Day.Date > maxDate)
{
e.Day.IsSelectable = false;
}
if (e.Day.Date >= minDate && e.Day.Date.Date <= maxDate)
{
e.Cell.BackColor = Color.FromName("#3f97ab");
}
}
DataTable dtgv = Session["dtSelectedDateData"] as DataTable;
if (dtgv != null)
{
foreach (DataRow drr in dtgv.Rows)
{
string DateValue = drr["Time_Start"].ToString();
if (e.Day.Date.ToString("dd/MM/yyyy") == DateValue.Substring(0, 10))
{
e.Cell.ForeColor = System.Drawing.Color.Pink;
e.Day.IsSelectable = false;
}
}
}
if (e.Day.IsSelected == true)
{
PatientsSchedule.listDatetime.Add(e.Day.Date);
}
Session["SelectedDate"] = PatientsSchedule.listDatetime;
}
public static List<DateTime> listDatetime = new List<DateTime>();
【问题讨论】:
-
jquery 日历?举几个例子
-
我在CalendarMain_DayRender方法下使用asp日历,每次选择一个日期,都会添加到一个静态
- 中。我在我的问题中添加了我的代码。 =)