如何在asp日历上更改未来日期的背景颜色 [英] how do I change back color of future dates on asp calendar
本文介绍了如何在asp日历上更改未来日期的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何更改asp.net日历的背景颜色?以后的日期只有
我有以下代码:
How do I change the background color of my asp.net calendar? the future dates only
I have the following code:
txtDateofAccident.Attributes["max"] = DateTime.Now.ToString("yyyy-MM-dd");
我想将未来日期的背景颜色设置为红色。
例如,今天可能是1,
所以日期可能从2开始黑色为红色
I want to set the background color of future dates to red.
for example, today is may 1,
so that dates from may 2 onwards black color is red
推荐答案
执行以下操作
do as below
<asp:Calendar id="calendar1"
OnDayRender="DayRender"
runat="server">
void DayRender(Object source, DayRenderEventArgs e)
{
if (e.Day.Date > DateTime.Now.Date)
e.Cell.BackColor=System.Drawing.Color.Red;
}
你已经在DayRender事件上写了代码(DamithSL是正确的)
You have write the code on DayRender event (DamithSL is correct)
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (!e.Day.Date > DateTime.Now.Date)
e.Cell.BackColor=System.Drawing.Color.Red;
}
这篇关于如何在asp日历上更改未来日期的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文