标签:
Calendar
日程控件
属性
Borderstyle 边框样式
DayNameFormat 日标头的文本格式
FirstDayOfWeek
NextPrevFormat 月导航按钮的格式
方法
DayRender() 在呈现日时激发
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { //1、清掉每个日期格中的所有控件。 e.Cell.Controls.Clear(); //2、为每个日期格添加一个格头 Label lblHead = new Label(); lblHead.Text = e.Day.Date.Day.ToString(); //获取格中的日期 lblHead.Width = Unit.Percentage(100); lblHead.BackColor = System.Drawing.Color.FromName("orange"); lblHead.Font.Bold = true; //3、给lblHead加上双击弹出添加日程功能 lblHead.Attributes.Add("ondblclick","window.open(‘Add.aspx?d="+e.Day.Date.ToString("yyyy-MM-dd")+"‘,‘_blank‘,‘width=500 height=400 toolbar=no‘)"); e.Cell.Controls.Add(lblHead); //4、查询数据库,加载每天的事件信息 var query = _Context.RiCheng.Where(p=>p.Date == e.Day.Date); foreach (RiCheng data in query) { Label lblItem = new Label(); lblItem.Attributes.Add("key", data.Ids.ToString()); lblItem.CssClass = "dayitem"; lblItem.Text = data.Title; lblItem.Width = Unit.Percentage(100); lblItem.BackColor = System.Drawing.Color.FromName(data.Color); e.Cell.Controls.Add(lblItem); } }
标签:
原文地址:http://www.cnblogs.com/phantom-k/p/4297790.html