Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Razor @() inside attribute value Not working

$
0
0

Hello

I have a view as follows that is not working: model is: @model IEnumerable<RoleModel>

@for (int i = 0; i < Model.Count(); i++)
{<input type="hidden" name="hdn_@([i].Text)" value="[@i].Text" />
}

the  attribute that is set to: name="hdn_@([i].Text)" gives me an error:

Invalid expression term '['

I also get an error in another view that is:

<input type="checkbox" asp-for="@Model.IsApproved" checked=@(Model.IsApproved? 'checked':'') />

for the checked attribute. I used the same syntax  @() in previous versions of mvc with no problem why this doesn't work?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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