I either get a “you need a ; here” or a “best overloaded match has invalid arguments” errors.
<tbody>
<tr>
@for (int i = 0; i < startDay; ++i)
{
@:<td><span></span><span></span></td>
}
@for (int j = startDay; j < ((numberOfDays + startDay) - 1); ++j)
{
<td>
<span>@startCount</span>
<br />
<span>
@{
var todaysEvents = Model.ToList().FindAll(d => d.CalDate.Day == j);
foreach(HTMLMVCCalendar.Models.CalendarModel eventsToday in todaysEvents)
{
foreach(HTMLMVCCalendar.Models.EventModel eventToday in eventsToday.CalEvents)
{
@eventToday.DayCode.ToString // error here
@:<br />
@eventToday.Subject // error here
@:<br />
@eventToday.EventDesc //error here
}
@:<br />
}
}
</span>
</td>
if ((j + 1) % 7 == 0)
{
@:</tr><tr>
}
@++startCount;
}
</tr>
</tbody>
Use a
<text>element rather than using the@before every piece of text you want to display. Convert:To:
I also removed the
.ToString(which was missing the parentheses) because objects are converted to strings implicitly when using the@symbol.Another thing, you have this code:
This needlessly increases your nesting. Contrary to our intuition, Razor blocks that begin with
@do not actually form a closed scope like it would in C#. Therefore, you can write it as:As you can see (if you run it),
todaysEventsis still accessible.