3,598 questions
Yes, you can add a "click" event to the cell.
so, assuming this markup for the calendar:
<asp:Calendar ID="Calendar1" runat="server" Height="751px" Width="1200px"
BorderColor="Black"
BorderStyle="Solid" BorderWidth="2px">
<DayHeaderStyle Height="40px" />
<DayStyle BorderStyle="Solid"
BorderColor="Black"
BorderWidth="1"
HorizontalAlign="Right"
VerticalAlign="Top" Height="80px" />
<OtherMonthDayStyle BackColor="LightSteelBlue" />
<SelectorStyle CssClass="btn-info" />
<TitleStyle Height="40px" />
<TodayDayStyle BackColor="LightSkyBlue" />
<WeekendDayStyle BackColor="Ivory" Height="60px" />
</asp:Calendar>
So, now in the day render event, you add this:
Protected Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.IsSelected Then
e.Cell.BackColor = System.Drawing.Color.LightCoral
End If
e.Cell.Attributes.Add("OnClick", e.SelectUrl)
End Sub
And the day click event (date change), is this:
Protected Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1.SelectionChanged
' day sel
Debug.Print(Calendar1.SelectedDate)
End Sub
And now the result is this: