Wednesday, January 21, 2009

Calendar Day Render Event in Asp.Net

Drag the Calendar control on to the Design view of the Page.

Then select the Day Render event of Calendar and paste the following code into it.

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

{
e.Cell.VerticalAlign = VerticalAlign.Top;
if (e.Day.Date == Convert.ToDateTime("01/27/2009"))
{
e.Cell.Controls.Add(new LiteralControl("

Sheeban Ahmed Birthday!

"));
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.BorderWidth = 1;
e.Cell.BorderStyle = BorderStyle.Solid;
e.Cell.BackColor = System.Drawing.Color.LightGray;
}
}

After running that Page you will have a screenshot like that

No comments:

Post a Comment