The razor engien have been bugging me a bit today. I have to set a variable lastAnime = c.Anime.Name but i just get the error
No overload for method ‘Write’ takes 0 arguments
@{ var lastAnime = ""; }
<select name="character">
<option value="">All</option>
@foreach (var c in Model.Characters) {
if (lastAnime != c.Anime.Name) {
@{lastAnime = c.Anime.Name;}
<optgroup title="@c.Name">
}
if(lastAnime != "") {
</optgroup>
}
<option value="@c.Id">@c.Name</option>
}
</select>
How can i do this?
Change it to look like this: (take out the @ block around your assignement statement)