<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
{
Image Image1 = new Image();
Image1.ImageUrl = "~/Image/bird.jpg";
Image1.Width = 75;
Literal Literal1 = new Literal();
Literal1.Text = "<br />";
e.Cell.Font.Italic = true;
e.Cell.BackColor = System.Drawing.Color.DarkKhaki;
e.Cell.BorderColor = System.Drawing.Color.Khaki;
e.Cell.ForeColor = System.Drawing.Color.Crimson;
e.Cell.Font.Name = "MS Sans Serif";
e.Cell.Style.Add("Padding","5px");
e.Cell.Controls.AddAt(0, Image1);
e.Cell.Controls.AddAt(1,Literal1);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to add an image in Calendar Day Cell</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to add an image 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="SeaGreen"
BorderColor="Green"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<SelectedDayStyle
BackColor="DarkGreen"
BorderColor="ForestGreen"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
{
Image Image1 = new Image();
Image1.ImageUrl = "~/Image/bird.jpg";
Image1.Width = 75;
Literal Literal1 = new Literal();
Literal1.Text = "<br />";
e.Cell.Font.Italic = true;
e.Cell.BackColor = System.Drawing.Color.DarkKhaki;
e.Cell.BorderColor = System.Drawing.Color.Khaki;
e.Cell.ForeColor = System.Drawing.Color.Crimson;
e.Cell.Font.Name = "MS Sans Serif";
e.Cell.Style.Add("Padding","5px");
e.Cell.Controls.AddAt(0, Image1);
e.Cell.Controls.AddAt(1,Literal1);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to add an image in Calendar Day Cell</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:SlateBlue; font-style:italic;">
How to add an image 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="SeaGreen"
BorderColor="Green"
BorderWidth="1"
Font-Bold="true"
Font-Italic="true"
Font-Size="Large"
/>
<NextPrevStyle
Font-Italic="true"
Font-Names="Arial CE"
/>
<SelectedDayStyle
BackColor="DarkGreen"
BorderColor="ForestGreen"
/>
<TitleStyle
BackColor="MidnightBlue"
Height="36"
Font-Size="Large"
Font-Names="Courier New Baltic"
/>
</asp:Calendar>
</div>
</form>
</body>
</html>
No comments:
Post a Comment