Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using   in Visual Studio 10 ASP.NET MVC3

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>            
&nbsp;
       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

like image 838
Babu James Avatar asked Dec 10 '12 07:12

Babu James


1 Answers

Change your code to

<div class="week">
    @for (int i = 0; i < 7; i++)
    {
        <div class="day">
            @weekStartDay.ToString().Substring(0, 3)
        </div>            
       @:&nbsp;
       weekStartDay = (DayOfWeek)(((int)weekStartDay + 1) % 7);
    }
</div>

@: tells the Razor view engine &nbsp; is plain text

like image 160
heads5150 Avatar answered Sep 23 '22 03:09

heads5150