2013-04-26 2 views
0

화면에 캘린더를 표시하고 있습니다. 캘린더는 '일기 항목'목록에 저장된 날짜를 강조 표시합니다. ATM 사용자는 달력의 상단에있는 화살표를 사용하여 모든 연도를 탐색 할 수 있습니다. 사용자가 날짜를 저장하는 달 사이를 탐색 할 수 있도록하려는 경우 예를 들어 날짜가 btn 1/3/2013 & 4/7/2013 일 경우 사용자가 캘린더를 2013 년 5 월 8 일로 옮길 수 없습니다. 화살표 키가 날짜를 눌렀을 때 화살표 키를 사용하지 못하게 할 수 있습니까?목록에없는 캘린더에서 달을 사용하지 않음

<asp:Calendar ID="calendarToDisplayWorkSiteDates" VerticalAlign="top" HorizontalAlign="left" runat="server" OnSelectionChanged="LoadRequestedDate_OnClick" OnDayRender="cal_DayRender"></asp:Calendar> 

public void BindData() 
     { 
      DateTime Date = new DateTime(DiaryDate.Year, DiaryDate.Month, 1); 
      DateTime startOfMonth = Date.AddMonths(-2); 
      DateTime endOfMonth = startOfMonth.AddMonths(5).AddDays(-1); 

      int siteId = this.siteId; 

      ClarkeDBDataContext db = new ClarkeDBDataContext(); 
      List<Diary_Entry> DiaryEntry = new List<Diary_Entry>(); 

      DiaryEntry = (from DE in db.Diary_Entries 
          where DE.Site_Id == siteId 
          && DE.Date >= startOfMonth && DE.Date <= endOfMonth 
          orderby DE.Date ascending 
          select DE).ToList(); 

      if (DiaryEntry != null) 
      { 
       FirstDateLabel.Text = DiaryEntry.FirstOrDefault().Date.Date.ToShortDateString(); 
       SecondDateLabel.Text = DiaryEntry.LastOrDefault().Date.Date.ToShortDateString(); 

       foreach (DateTime d in DiaryEntry.Select(de => de.Date)) 
       { 
        calendarToDisplayWorkSiteDates.SelectedDates.Add(d); 
       } 
      } 

      else 
      { 
       FirstDateLabel.Text = "None"; 
       SecondDateLabel.Text = "None"; 
      } 


     } 

     protected void cal_DayRender(object sender, DayRenderEventArgs e) 
     { 
      if (e.Day.IsToday) 
       e.Cell.BackColor = Color.Red; 
      else if (e.Day.Date == this.DiaryDate) 
       e.Cell.BackColor = Color.Green; 
      else if (e.Day.IsSelected) 
       e.Cell.BackColor = Color.Blue; 
     } 

답변

0

나는 그것이 화살표를 해제하는 (쉽게) 할 수 있다고 생각하지 않는다, 가장 쉬운 방법은 IsSelectable property을 설정 DayRender 이벤트를 사용하는 것입니다.

protected void cal_DayRender(object sender, DayRenderEventArgs e) 
{ 
    if (e.Day.IsToday) 
     e.Cell.BackColor = Color.Red; 
    else if (e.Day.Date == this.DiaryDate) 
     e.Cell.BackColor = Color.Green; 
    else if (e.Day.IsSelected) 
     e.Cell.BackColor = Color.Blue; 
    // adjust accordingly 
    if (e.Day.Date < MinDate || e.Day.Date > MaxDate) 
    { 
     e.Day.IsSelectable = false; 
     e.Cell.BackColor = Color.LightGray; 
    } 
} 
+0

도움을 주신 분들께 감사드립니다. Tim – John

+0

@ 존 : 환영합니다. 당신은 대답을 받아 들일 수 있습니다 :) –

관련 문제