Barnabeck
Barnabeck

Reputation: 481

How to select the "selected Date" in asp:Calendar?

The question sounds illogical, but it is not:

I have 2 dates "Target" and "Actual". Usually the "Actual" date is very close to "Target", but not necessarily to the current date. To avoid the multiple clicks in the calendar that would navigate you to the month/year of interest, I set the selected date to my "Target" date when it is opened. This works great, BUT does not allow me to select that day, with the calendar closing automatically after selecting.

Any idea to solve this or any known alternative?

Upvotes: 0

Views: 1838

Answers (1)

Enrico
Enrico

Reputation: 6202

If you have a Calendar1 component, you can use a code like:

DateTime tomorrow = DateTime.Today.AddDays(1);
Calendar1.TodaysDate = tomorrow;
Calendar1.SelectedDate = Calendar1.TodaysDate;

When this calendar changed SelectionChanged the selected date, you can set the other calendar.

Tell me if you need more detail.

Upvotes: 1

Related Questions