Geeks With Blogs

News

Microsoft MVP


DZone MVB


Moderator at CodeASP.NET


Quiz Master







free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

Here an example on how to disable  or set the calendar previous dates to not selectable.

ASPX:

<asp:Calendar ID="Calendar1" TodayDayStyle-Font-Underline="false" 
              runat="server" 
              SelectionMode="None" 
              OnDayRender="Calendar1_DayRender" >
              <DayStyle Font-Underline="False" Wrap="False" />
</asp:Calendar>

RELEVANT CODE:

  protected void Calendar1_DayRender(object sender, DayRenderEventArgs e){
        if (e.Day.Date < DateTime.Now.Date){
            e.Day.IsSelectable = false;
            e.Cell.ForeColor = System.Drawing.Color.Gray;
        }
  }

Technorati Tags: ,,
Posted on Sunday, May 3, 2009 5:51 PM ASP.NET , C# , Tips&Tricks | Back to top


Comments on this post: How to: Disable Previous Dates in Calendar Control

# re: How to: Disable Previous Dates in Calendar Control
Requesting Gravatar...
Nice work
Left by Vivek Jain on Jun 07, 2009 2:06 PM

# re: How to: Disable Previous Dates in Calendar Control
Requesting Gravatar...
Nice and lovely, I tried it and it worked fine
Left by Yousif Shehab on Feb 07, 2010 12:54 AM

# re: How to: Disable Previous Dates in Calendar Control
Requesting Gravatar...
good stuff
Left by srikanth on Jul 16, 2010 3:19 PM

# re: How to: Disable Previous Dates in Calendar Control
Requesting Gravatar...
hi thanks a lot
it is working fine
Left by kishan on Sep 20, 2012 8:03 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net