【发布时间】:2012-09-04 16:18:06
【问题描述】:
我正在尝试将鼠标悬停在颜色更改功能上添加到 ASP.NET 中的默认日历。到目前为止,我已经尝试实现以下代码:
Color col = new Color();
col = Calendar1.DayStyle.BackColor;
if (col != Color.Empty)
{
e.Cell.Attributes["onmouseover"] = "this.style.backgroundColor='pink';";
e.Cell.Attributes["onmouseout"] = "this.style.backgroundColor='" + col + "';";
}
else
{
e.Cell.Attributes["onmouseover"] = "this.style.backgroundColor='pink';";
e.Cell.Attributes["onmouseout"] = "this.style.backgroundColor='';";
}
如果我不点击日期,一切似乎都正常。但是,当我单击日期并且日期背景变为灰色时,背景颜色变为粉红色,然后再次变为白色。这似乎是因为不知何故
col = Calendar1.DayStyle.BackColor;
没有选择正确的背景颜色?
这里有什么我错过的吗?
【问题讨论】:
-
不,这是因为onmouserover和onmouseout事件之后触发,它变成粉红色而不是白色。
标签: c# asp.net calendar mouseover