calendar控件中DIV颜色问题
protected void cal1_DayRender(object sender, DayRenderEventArgs e)
{
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
c.Controls.Add(new LiteralControl( " <br> "));
c.Controls.Add(new LiteralControl( " <div style= 'background-color:#efefef '> "));
c.Controls.Add(a);
c.Controls.Add(new LiteralControl( " </div> "));
}
这是在calendar控件中添加日程时候的代码,加个div是让每个显示的日程在div中,
但是这段代码中div的颜色是指定的,我想达到用户在下拉里面选择什么颜色,
( " <div style= 'background-color:#efefef '> "));
这里就变成用户所选的那种颜色。。。
如何改写???
------解决方案--------------------js,把对应代码传进去就行了
------解决方案--------------------protected void cal1_DayRender(object sender, DayRenderEventArgs e)
{
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
c.Controls.Add(new LiteralControl( " <br> "));
c.Controls.Add(new LiteralControl( " <div style= 'background-color: " + this.DropDownList1.SelectedValue + " '> "));//DropDownList1.SelectedValue为颜色的名字。
c.Controls.Add(a);
c.Controls.Add(new LiteralControl( " </div> "));
}
把DropDownList1的AutoPostBack设为true;