给你个简单的例子
private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
// Change the background color of the days in the month to yellow.
if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
e.Cell.BackColor=System.Drawing.Color.Yellow;
// Add custom text to cell in the Calendar control.
if (e.Day.Date.Day == 18)
e.Cell.Controls.Add(new LiteralControl("<br>Holiday"));
}
Private Sub calDate_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calDate.DayRender
Dim i As Integer
Dim p_stuHoliday As DateColorData()
Dim kk As New System.Web.UI.WebControls.Label
Try
p_stuHoliday = CType(Page.Session("RmPrintInfo")
If (e.Day.Date.DayOfWeek = DayOfWeek.Saturday) And (Not e.Day.IsOtherMonth) Then
e.Cell.ForeColor = System.Drawing.Color.Blue
ElseIf (e.Day.Date.DayOfWeek = DayOfWeek.Sunday) And (Not e.Day.IsOtherMonth) Then
e.Cell.ForeColor = System.Drawing.Color.Red
End If
If Not IsNothing(p_stuHoliday) Then
For i = 0 To p_stuHoliday.Length - 1
If Not e.Day.IsOtherMonth Then
If e.Day.Date.Date = p_stuHoliday(i).holiday_date Then
e.Cell.ForeColor = System.Drawing.Color.FromArgb(p_stuHoliday(i).color_red, p_stuHoliday(i).color_green, p_stuHoliday(i).color_blue)
kk.Text = "<br>外出"
e.Cell.Controls.Add(kk)
End If
End If
Next
End If
Catch ex As Exception
Throw ex
Finally
End Try
End Sub
Private Sub calDate_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calDate.DayRender
Dim i As Integer
Dim p_stuHoliday As DateColorData()
Try
p_stuHoliday = CType(Page.Session("RmPrintInfo")
If (e.Day.Date.DayOfWeek = DayOfWeek.Saturday) And (Not e.Day.IsOtherMonth) Then
e.Cell.ForeColor = System.Drawing.Color.Blue
ElseIf (e.Day.Date.DayOfWeek = DayOfWeek.Sunday) And (Not e.Day.IsOtherMonth) Then
e.Cell.ForeColor = System.Drawing.Color.Red
End If
If Not IsNothing(p_stuHoliday) Then
For i = 0 To p_stuHoliday.Length - 1
If Not e.Day.IsOtherMonth Then
If e.Day.Date.Date = p_stuHoliday(i).holiday_date Then
e.Cell.ForeColor = System.Drawing.Color.FromArgb(p_stuHoliday(i).color_red, p_stuHoliday(i).color_green, p_stuHoliday(i).color_blue)
e.Cell.Text="XXXXXXXXXXXXXXXXX"
End If
End If
Next
End If
Catch ex As Exception
Throw ex
Finally
End Try
End Sub