Vinz' Blog

"Code, Beer and Music" ~ my way of being a programmer!
posts - 124, comments - 365, trackbacks - 0

My Links

News

Archives

Image Galleries

How to: Disable Previous Dates in Calendar Control

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;

        }

    }

Print | posted on Sunday, May 03, 2009 5:51 PM |

Feedback

Gravatar

# re: How to: Disable Previous Dates in Calendar Control

Nice work
6/7/2009 2:06 PM | Vivek Jain
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: