How to add Literal control in Calendar Day Cell
AddLiteralInCalendarDayCell.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<script runat="server">
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
{
Literal Literal1 = new Literal();
Literal1.Text ="<br /><font size=-1 color=Snow>ToDay</font>";
e.Cell.Font.Italic = true;
e.Cell.Font.Size = FontUnit.XLarge;
e.Cell.BackColor = System.Drawing.Color.DodgerBlue;
e.Cell.BorderColor = System.Drawing.Color.SkyBlue;
e.Cell.ForeColor = System.Drawing.Color.Wheat;
e.Cell.Font.Name = "Courier New";
e.Cell.Controls.AddAt(1,Literal1);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to add Literal control in Calendar Day Cell</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to add Literal control in Calendar Day Cell
</h2>
<hr width="475" align="left" color="SlateGray" />
<asp:Calendar
ID="Calendar1"
runat="server"
NextPrevFormat="FullMonth"
ForeColor="WhiteSmoke"
SelectionMode="Day"
DayNameFormat="Full"
Font-Names="Book Antiqua"
Font-Size="Medium"
OnDayRender="Calendar1_DayRender"
>
<DayHeaderStyle
BackColor="OliveDrab"
/>
<DayStyle
BackColor="DarkBlue"
BorderColor="CornflowerBlue"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<SelectedDayStyle
BackColor="Crimson"
BorderColor="Pink"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>


