In this article I will explain with an example, how to set a Custom Date as Today’s Date (Selected Date) programmatically in ASP.Net Calendar control using C# and VB.Net.
HTML Markup
The following HTML Markup consists of an ASP.Net Calendar control.
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
Set Custom Date as Today's Date (Selected Date) in ASP.Net Calendar
Inside the Page Load event, the TodaysDate and SelectedDate properties of the ASP.Net Calendar control are set with a Custom date.
Note: Both TodaysDate and SelectedDate properties need to be set with same Date value then only the Calendar control will display the Date as selected.
C#
protected void Page_Load(object sender, EventArgs e)
{
Calendar1.TodaysDate = new DateTime(2019,12, 23);
Calendar1.SelectedDate = new DateTime(2019, 12, 23);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Calendar1.TodaysDate = New DateTime(2019, 12, 23)
Calendar1.SelectedDate = New DateTime(2019, 12, 23)
End Sub
Screenshot
Demo
Downloads