Reputation: 369
I have calendar control in my page. It displayed all days of the week. Now, I want to delete Wednesday from the calender control. Only six days need to displayed.
I tried this:
if (e.Day.Date.DayOfWeek == DayOfWeek.Wednesday)
{
e.Cell.Visible = false;
// e.Cell.Text = string.Empty;
// e.Day.IsSelectable = false;
// e.Cell.ForeColor = System.Drawing.Color.Red;
}
It is not working like expected. How do I delete a whole day from the calendar?
thanks for help in advance, Ulas
Upvotes: 0
Views: 1562
Reputation: 3010
The following works for me:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date.DayOfWeek == DayOfWeek.Wednesday)
{
e.Cell.Controls.Clear();
}
}
It does leave the header (Wed) though, as mentioned in the comments below this can be fixed by adding the following to the CSS file:
.calendar tr > th:first-child + th + th + th + { display:none; }
Upvotes: 0