Search code examples
htmlasp.netajaxcalendarextender

How to set current date in CalendarExtender


Requirement is simple.

How to set current date in CalendarExtender control.

<cal:CalendarExtender ID="calDate" runat="server" SelectedDate="2008-01-01" TargetControlID="txtDate" CssClass="CalendarExtender" Format="yyyy/MM/dd">

Here the selected date is 2008-01-01. I need to show current date instead of 2008-01-01

Appreciate your assistance


Solution

  • You just need to assign it in codebehind, for example in Page_Load:

    if(!IsPostBack)
       calDate.SelectedDate = DateTime.Today;