Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
See razor code below:
<li class="@Library.If(isSelected, "active", "")"> <a href="@page.Url">@page.Name</a> </li>
Generates this:
<li class="active"><a href="/kontakt.aspx">Kontakt</a></li>
But i need it to generate this:
<li><a href="about.html" class="active">About</a></li>
Above it places "class="active" outside <li> and after href.
Thank you in advance. :-)
Hi René
Try moving the logic inside the a:
<li> <a href="@page.Url" class="@Library.If(isSelected, "active", "")">@page.Name</a></li>
Hope it works
Hi Kasper
Thank you!
It works but i puts in a blank class="" on links that are not selected, does it matter?
You can solve it by moving the class="" inside the if.
<li> <ahref="@page.Url"@Library.If(isSelected, "class=\"active\"", "")>@page.Name</a></li>
Glad I could help. Please mark your post as solved so others can see this has an answer :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Razor - Top navigation active link
Hi
See razor code below:
Generates this:
<li class="active"><a href="/kontakt.aspx">Kontakt</a></li>
But i need it to generate this:
<li><a href="about.html" class="active">About</a></li>
Above it places "class="active" outside <li> and after href.
Thank you in advance. :-)
Hi René
Try moving the logic inside the a:
Hope it works
Hi Kasper
Thank you!
It works but i puts in a blank class="" on links that are not selected, does it matter?
You can solve it by moving the class="" inside the if.
Glad I could help. Please mark your post as solved so others can see this has an answer :-)
is working on a reply...