Good day,
I'm trying to create a dynamic calendar using HTML table. I have a few problems that I'm facing right now.
I have no idea how to specify if the specific first day of the month is Sunday, Monday, Tuesday, Wednesday, Thursday or Saturday.
How to fix my table body to show the table properly layout like a calendar.
So far, these are my codes in my razor page.
@{ // responsible for getting the first and last days of the month
var getDate = DateTime.Now;
var firstDayOfTheMonth = new DateTime(getDate.Year, getDate.Month, 1);
var lastDayOfTheMonth = firstDayOfTheMonth.AddMonths(1).AddDays(-1);
var numberOfDays = Convert.ToInt16(lastDayOfTheMonth.ToString("dd"));
}
// My HTML table
<table border="1">
<thead>
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
</thead>
<tbody>
<tr>
@for (var i = 0; i < numberOfDays + 1; i++)
{
<td>@i</td>
}
</tr>
</tbody>
Thank you in advance.
