Tech Tidbits - Ruby, Ruby On Rails, Merb, .Net, Javascript, jQuery, Ajax, CSS...and other random bits and pieces.

Wednesday, November 21, 2007

ASP.NET Calendar Control - Misc

How to: Display Selected Dates from a Database in the Calendar Control

Hide days that aren't in current month:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date.Month != Calendar1.VisibleDate.Month)
e.Cell.Text = "";
}


Disable link for particular day (the 23rd, in this case):

protected void cal_DayRender(object source, DayRenderEventArgs e)
{
if (e.Day.Date.Day == 23)
{
e.Cell.Controls.Clear();
e.Cell.Text = e.Day.DayNumberText;
e.Cell.BackColor = System.Drawing.Color.Gainsboro;
}
}

No comments:

About Me

My photo
Developer (Ruby on Rails, iOS), musician/composer, Buddhist, HSP, Vegan, Aspie.

Labels