如何正確寫入MVC 3 Razor?Razor MVC 3中的Html
<li <%if(ViewContext.RouteData.Values["Controller"].ToString() == "Home"){%> class="active"<%} %>><a href="@Url.Action("index", "Home")">Home</a></li>
祝福
編輯
這是我的代碼,不工作:(
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">CYSAC 2.0</a>
<ul class="nav">
<li @(ViewContext.RouteData.Values["Controller"].ToString() == "Home" ? "class=\"active\"" : string.Empty)><a href="@Url.Action("index", "Home")">Inicio</a></li>
<li @(ViewContext.RouteData.Values["Controller"].ToString() == "University" ? "class=\"active\"" : string.Empty)><a href="@Url.Action("index", "University")">University</a></li>
<li @(ViewContext.RouteData.Values["Controller"].ToString() == "Estudent" ? "class=\"active\"" : string.Empty)><a href="@Url.Action("index", "Estudent")">Estudent</a></li>
</ul>
</div>
</div><!-- /navbar-inner -->
</div><!-- /navbar -->
請幫助
@jrummell請參閱我的編輯 – kalu
@kalu - define「不起作用」,並且您看過輸出的HTML嗎? –