I am using Visual Studio 2010 Professional edition for developing an application in ASP.NET MVC3 framework.
I have come across a situation where I need to have a literal space character, usually accomplished by adding
(something similar) in HTML.
However, program gives a run-time error.
How do I overcome this?
Code:
<div class="week">
@for (int i = 0; i < 7; i++)
{
<div class="day">
@weekStartDay.ToString().Substring(0, 3)
</div>
weekStartDay = (DayOfWeek)(((int)weekStartDay + 1) % 7);
}
</div>
Error:
c:***\Documents\Visual Studio 2010\Projects\MvcApplication2\MvcApplication2\Views\Home\Calendar.cshtml(22): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Change your code to
<div class="week">
@for (int i = 0; i < 7; i++)
{
<div class="day">
@weekStartDay.ToString().Substring(0, 3)
</div>
@:
weekStartDay = (DayOfWeek)(((int)weekStartDay + 1) % 7);
}
</div>
@: tells the Razor view engine
is plain text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With