Hi amitj,
I have created sample code which fullfill your requirement.
HTML
<div>
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"
BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="200px"
ondayrender="Calendar1_DayRender" ShowGridLines="True" Width="220px">
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyle BackColor="#FFCC66" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
</asp:Calendar>
</div>
C#
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
dt.Columns.Add("EventName");
dt.Columns.Add("Date", typeof(DateTime));
dt.Rows.Add("Party", DateTime.Now.Date);
dt.Rows.Add("Exam", DateTime.Now.Date.AddDays(5));
dt.Rows.Add("Study", DateTime.Now.Date.AddDays(10));
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
foreach (DataRow row in dt.Rows)
{
if (Convert.ToDateTime(e.Day.Date) == Convert.ToDateTime(row["Date"]))
{
e.Cell.Text = e.Day.DayNumberText + "<br/>" + row["EventName"].ToString();
}
}
}
vb.net
Private dt As New DataTable()
Protected Sub Page_Load(sender As Object, e As EventArgs)
dt.Columns.Add("EventName")
dt.Columns.Add("Date", GetType(DateTime))
dt.Rows.Add("Party", DateTime.Now.[Date])
dt.Rows.Add("Exam", DateTime.Now.[Date].AddDays(5))
dt.Rows.Add("Study", DateTime.Now.[Date].AddDays(10))
End Sub
Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs)
For Each row As DataRow In dt.Rows
If Convert.ToDateTime(e.Day.[Date]) = Convert.ToDateTime(row("Date")) Then
e.Cell.Text = e.Day.DayNumberText + "<br/>" + row("EventName").ToString()
End If
Next
End Sub
Screenshot
