Calendar date blocking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suganya
    New Member
    • Dec 2006
    • 39

    Calendar date blocking

    Hi

    I have to block all previous date in calendar. for that I have given coding as


    protected void QuickCalendar_D ayRender(object sender,
    System.Web.UI.W ebControls.DayR enderEventArgs e)
    {
    if ((e.Day.Date < DateTime.Now))
    {
    e.Day.IsSelecta ble = false;
    }
    }

    But if i give that its blocking todays date also. I want todays date to be active.
  • MyteC
    New Member
    • Sep 2008
    • 3

    #2
    Did you try an else?
    if < today block
    else is selectable = true

    Comment

    • cloud255
      Recognized Expert Contributor
      • Jun 2008
      • 427

      #3
      Hi there, i tried your code with one small change and it worked for me:

      Code:
      if ((e.Day.Date < DateTime.Now.[B]Date[/B]))
      {
      e.Day.IsSelectable = false;
      }
      This happens because the date returned from the control is at the very first second of the day i.e. midnight. DateTime.Now returns the current time including seconds thus, the start of the day is always less than the any other time of that day.

      Comment

      Working...