Hi nisss,
What you are looking is not possible. But you can do it like below.
On DayRender event assign color to the public holiday cell and change the tooltip of the cell. When you hover on the day respective details will be displayed as tooltip.
Check the below sample.
HTML
<asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender" BackColor="White"
BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana"
Font-Size="7pt" ForeColor="Black" Height="100px" OnSelectionChanged="cstart_SelectionChanged"
Width="100px">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
Code
C#
private System.Data.DataTable GetData()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Date");
dt.Columns.Add("Desc");
dt.Rows.Add("2020-01-01 15:23:34.123", "Happy New Year");
dt.Rows.Add("2020-01-14 15:23:34.123", "Sultan's Birthday");
dt.Rows.Add("2020-02-01 15:23:34.123", "Federal Territory Day");
return dt;
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
System.Data.DataTable dt = GetData();
foreach (System.Data.DataRow row in dt.Rows)
{
if (Convert.ToDateTime(e.Day.Date).ToShortDateString() == Convert.ToDateTime(row["Date"]).ToShortDateString())
{
e.Cell.BackColor = System.Drawing.Color.Red;
e.Cell.ToolTip = row["Desc"].ToString();
e.Cell.Controls.Clear();
HyperLink link = new HyperLink();
link.Text = Convert.ToString(e.Day.Date.Day);
link.ToolTip = row["Desc"].ToString();
link.NavigateUrl = e.SelectUrl;
e.Cell.Controls.Add(link);
}
else
{
e.Cell.ToolTip = e.Day.Date.ToString("MMMM dd");
}
}
}
protected void cstart_SelectionChanged(object sender, EventArgs e)
{
}
VB.Net
Private Function GetData() As System.Data.DataTable
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.Add("Date")
dt.Columns.Add("Desc")
dt.Rows.Add("2020-01-01 15:23:34.123", "Happy New Year")
dt.Rows.Add("2020-01-14 15:23:34.123", "Sultan's Birthday")
dt.Rows.Add("2020-02-01 15:23:34.123", "Federal Territory Day")
Return dt
End Function
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
Dim dt As System.Data.DataTable = GetData()
For Each row As System.Data.DataRow In dt.Rows
If Convert.ToDateTime(e.Day.Date).ToShortDateString() = Convert.ToDateTime(row("Date")).ToShortDateString() Then
e.Cell.BackColor = System.Drawing.Color.Red
e.Cell.ToolTip = row("Desc").ToString()
e.Cell.Controls.Clear()
Dim link As HyperLink = New HyperLink()
link.Text = Convert.ToString(e.Day.Date.Day)
link.ToolTip = row("Desc").ToString()
link.NavigateUrl = e.SelectUrl
e.Cell.Controls.Add(link)
Else
e.Cell.ToolTip = e.Day.Date.ToString("MMMM dd")
End If
Next
End Sub
Protected Sub cstart_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Screenshot
