0

i have 2 DateTimeControl on my aspx page.

enter image description here

Is it possible to make that the second one begin at the selected date of the first one and make all the previous dates disabled?

I tried this on the code behind:

protected void StartDate_DateChanged(object sender, EventArgs e)
{
    EndDate.FirstDayOfWeek = StartDate.SelectedDate.Date.Day;
    //EndDate.FirstDayOfWeek = StartDate.SelectedDate.Day;
}

but this is not working...any clue?

0

Can you try this:

protected void StartDate_DateChanged(object sender, EventArgs e) 
    EndDate.MinDate = StartDate.SelectedDate; // starting date as DateTime object
}

FirstDayOfWeek specifies which day has to be first in the popup display. For instance, sometimes a week has to start on sunday (int value 0) instead of saturday (int value 6).

Default value is 0, so the week will start on sunday by default.

  • I set the start date mindate to today's date but in the event handler setting the mindate based on the selecteddate doesn't work – n0r1s Dec 6 '13 at 9:35
  • Is there any exception thrown? – Gert Braspenning Dec 6 '13 at 9:41
  • no...just the event seems to be never launched – n0r1s Dec 6 '13 at 9:50
  • Can you add the code where you attach the event? – Gert Braspenning Dec 6 '13 at 9:54
  • protected void Page_Load(object sender, EventArgs e) { StartDate.MinDate = DateTime.Today; EndDate.MinDate = DateTime.Today; StartDate.DateChanged += StartDate_DateChanged; } void StartDate_DateChanged(object sender, EventArgs e) { EndDate.MinDate = StartDate.SelectedDate; } – n0r1s Dec 6 '13 at 10:05
0

In your "DateChanged" event for the first control, you can set the "MinDate" property of the second control. That is the property that prevents any dates prior to the set date from being selected. See http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.webcontrols.datetimecontrol.mindate.aspx

  • I set the start date mindate to today's date but in the event handler setting the mindate based on the selecteddate doesn't work – n0r1s Dec 6 '13 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.