Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"\"@\" is not valid at the start of a code block

Here is my razor view.

@model IEnumerable<ApricaROI.Models.DatabaseEntities.SalesItemMapping>
@{
    var name_List = Model.GroupBy(x => x.Name).Select(y => y.First()).ToList();
}
@foreach (var name in Model.Select(item => item.Name).Distinct()) {
    <div id="item@@name" class='itemDivs'>
        @{ Html.RenderPartial("_EditItemChild",
                     Model.Where(item => item.Name== name).ToList()); }
    </div>
}

I don't know what kind of error it has. It is giving following error.

"\"@\" is not valid at the start of a code block.
Only identifiers, keywords, comments, \"(\" and \"{\" are valid.\r\n"
like image 735
Dhwani Avatar asked Dec 11 '22 07:12

Dhwani


1 Answers

I have read somewhere that @@ works in mvc3 i.e. razor 1.0. But somehow doesnt work in mvc4 razor-2.0

So try Changing

<div id="item@@name" class='itemDivs'>

to

<div id="item@("@name")" class='itemDivs'>
like image 151
Nitin Varpe Avatar answered Dec 25 '22 09:12

Nitin Varpe