问题
I have the following tabs in my Razor:
<div class="page-tabs">
<ul class="nav nav-tabs">
@if (!Model.OriginalWork.IsNew)
{
<li class='@(ViewBag.IsAmendment == "0" ? "active" : "")'>
<a href='@Url.Action("ReviewDetails", "SongsManagement", new { isAmendment = 0 }))' title="Original">Original</a>
</li>
<li class='@(ViewBag.IsAmendment == "1" ? "active" : "")'>
<a href='@Url.Action("ReviewDetails", "SongsManagement", new { isAmendment = 1 })' title="Amendment">Active Amendment</a>
</li>
}
</ul>
Only the second tab is showing as active when I click on it. When I click on the original its not changing?
回答1:
In first tab there is an extra parenthesis
<div class="page-tabs">
<ul class="nav nav-tabs">
@if (!Model.OriginalWork.IsNew)
{
<li class='@(ViewBag.IsAmendment == "0" ? "active" : "")'>
<a href='@Url.Action("ReviewDetails", "SongsManagement", new { isAmendment = 0
})' title="Original">Original</a>
</li>
<li class='@(ViewBag.IsAmendment == "1" ? "active" : "")'>
<a href='@Url.Action("ReviewDetails", "SongsManagement", new { isAmendment = 1 })' title="Amendment">Active Amendment</a>
</li>
}
</ul>
来源:https://stackoverflow.com/questions/51743347/tabs-in-razor-only-one-tab-is-active