我有一个日历,我需要一个按钮来更改月份,我要做的基本上是当您更改操作系统的日期时,它也更改了日历,我得到了我只需要的工作一个按钮,我不知道该怎么做或从哪里开始。
@ 这是我的观点,我认为不需要显示模型和控制器 @
int currentMonth = DateTime.UtcNow.Month;
int currentYear = DateTime.UtcNow.Year;
DateTime firstDay = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1);
DateTime lastDay = new DateTime(currentYear, currentMonth, Model.DaysOfMonth.Count);
int dayOfWeekFirst = ((int)firstDay.DayOfWeek > 0) ? (int)firstDay.DayOfWeek : 7;
<div class="col-sm-6 col-md-6 col-lg-6">
<table class="table color-table info-table table-bordered">
<thead>
<th>SEG</th>
<th>TER</th>
<th>QUA</th>
<th>QUI</th>
<th>SEX</th>
<th>SÁB</th>
<th>DOM</th>
</thead>
<tr>
<tbody>
<!-- filling up space of previous month -->
@for (int a = 1; a < dayOfWeekFirst; a++)
{
<td></td>
}
<!-- filling up space of current month -->
@for (int i = Model.DaysOfMonth[0].DayOfMonth; i <= Model.DaysOfMonth.Count; i++)
{
DateTime renderedDay = new DateTime(firstDay.Year, firstDay.Month, i);
// if Sunday
if (renderedDay.DayOfWeek == DayOfWeek.Sunday)
{
<td bgcolor="#666666">
<div class="checkbox">
<input type="checkbox" id="checkbox @i" value="check" hidden />
<label for="checkbox @i"></label>
</div>
<br />
<h3 align="right" style="color:black">@i</h3>
</td>
<tr></tr>
}
else if (renderedDay.DayOfWeek == DayOfWeek.Saturday)
{
<td bgcolor="#666666">
<div class="checkbox">
<input type="checkbox" id="checkbox @i" value="check" hidden />
<label for="checkbox @i"></label>
</div>
<br />
<h3 align="right" style="color:black">@i</h3>
</td>
}
else
{
<td bgcolor="#ffffff">
<div class="checkbox">
<input type="checkbox" id="checkbox @i" value="check" hidden />
<label for="checkbox @i"></label>
</div>
<br />
<h3 align="right" style="color:black">@i</h3>
</td>
}
}
</tbody>
</tr>
</table>
</div>
<div class="col-sm-2 col-md-2 col-lg-2" align="center">
<h1 style="color:dodgerblue">Div Direito</h1>
</div>