DayRenderEventArgs.Day Property
Gets the CalendarDay that represents the day being rendered in the Calendar control.
[Visual Basic] Public ReadOnly Property Day As CalendarDay [C#] public CalendarDay Day {get;} [C++] public: __property CalendarDay* get_Day(); [JScript] public function get Day() : CalendarDay;
Property Value
The CalendarDay that represents the day being rendered in the Calendar control.
Remarks
Use the Day property to get information about the day being rendered in the Calendar control.
Example
[Visual Basic, C#] The following example demonstrates how to use the Day property to determine whether the day being rendered in the Calendar control is in the current month and also a weekday.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub DayRender(source As Object, e As DayRenderEventArgs) If Not e.Day.IsOtherMonth And Not e.Day.IsWeekend Then e.Cell.BackColor = System.Drawing.Color.Yellow End If End Sub 'DayRender </script> </head> <body> <form runat="server"> <h3>DayRenderEventArgs Example</h3> <asp:Calendar id="calendar1" OnDayRender="DayRender" runat="server"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void DayRender(Object source, DayRenderEventArgs e) { if (!e.Day.IsOtherMonth && !e.Day.IsWeekend) e.Cell.BackColor=System.Drawing.Color.Yellow; } </script> </head> <body> <form runat="server"> <h3>DayRenderEventArgs Example</h3> <asp:Calendar id="calendar1" OnDayRender="DayRender" runat="server"> <WeekendDayStyle BackColor="gray"> </WeekendDayStyle> </asp:Calendar> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
DayRenderEventArgs Class | DayRenderEventArgs Members | System.Web.UI.WebControls Namespace | TableCell | CalendarDay | Calendar | DayRender