How to set current date in CalendarExtender

Padmanaban picture Padmanaban · Aug 21, 2015 · Viewed 9.5k times · Source

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

Answer

Tim Schmelter picture Tim Schmelter · Aug 21, 2015

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

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