c# - asp.net-mvc-6 active menu item by page -


<a asp-action="index" class="active" asp-controller="user">blah</a> <a asp-action="tarif" asp-controller="home">blah</a> <a asp-action="account" asp-controller="home">blah</a> 

with new asp-helpers cant insert @if () < text> class="active" < / text> in tag .

how make correctly , easier?

i know there lot of solutions, want know - how solve correctly in new asp.

to use complete statement inside element, need wrap {}.

<a asp-action="index" @{ if (isactive) { <text> class="active" </text> } } asp-controller="user">blah</a> 

to use expression when isn't detecting end properly, you'll want wrap ().

<a asp-action="index" class="@((isactive) ? "active" : "")" asp-controller="user">blah</a> 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -