I am totally new to C# and coding. I'm working on a challenge in a course I'm taking which in part needs to satisfy the following business rule:
Business Rule 1: Initialize the calendar controls. Make sure the end of the previous assignment date is set to today. Make sure the start date of the new assignment is set for an additional 14 days from today. Make sure the end date of the new assignment is set for an additional 21 days from today.
When I initially set these dates the selected date was correct, but since it is late in the month, I would have to click to the next month to see the selected date:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
previousCalendar.SelectedDate = DateTime.Now.Date;
newCalendar.SelectedDate = DateTime.Now.Date.AddDays(14);
endCalendar.SelectedDate = DateTime.Now.Date.AddDays(21);
}
so I added the following 2 lines of code (of course within the curly brackets) to show the selected date:
newCalendar.VisibleDate = newCalendar.SelectedDate;
endCalendar.VisibleDate = endCalendar.SelectedDate;
This seems a little cumbersome, is there a way to consolidate these last two lines?
Again, I'm a total noob so I'm sure the answer will be obvious to everyone else here.