Quantcast
Channel: RazorGenerator Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 525

Commented Unassigned: VS2012 + @if error [144]

$
0
0
Hi to all,
i'm new of this extension, and i think that is a great tool.

At the moment i use it to generate some html templates in a ASPX project, and in one of them i put an if statement to change the render of a select tag (see the code below).

```
@foreach (var value in Content)
{

@if (value.FieldValueSelected ) {
<option value="@value.FieldValueID" selected >@value.FieldValueName</option>
}
else
{
<option value="@value.FieldValueID" >@value.FieldValueName</option>
}
}
```

( value.FieldValueSelected is a boolean )

The project compile anche the template run correctly, but for visual studio 2012 i have an error and a warning:


* Warning: Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".


* Error : Custom tool error: Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".


At this time is not a problem for me because i can compile the project,.

Comments: This is Razor behavior. You only need @s when switching between html and C#. In your case, you're already in a code block and you could drop the @ preceeding the if

Viewing all articles
Browse latest Browse all 525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>