ASP.NET Calendar - Knowledge Base

« Back to Knowledge Base list

Set the current time

Q:

How to set the current time?

A:

Set property SelectedDate.

ASPX
        <obout:Calendar id="Calendar1" runat="server"
                ShowTimeSelector="true"
                DateFormat="MM/dd/yyyy hh:mm:ss" />


Set this code on Page_Load event.
C#
        Calendar1.SelectedDate = DateTime.Now;
        Calendar1.DateFirstMonth = DateTime.Now;


VB
        Calendar1.SelectedDate = DateTime.Now;
        Calendar1.DateFirstMonth = DateTime.Now;