我遇到了@helper中的Action鏈接問題。 看到下面這條線@helper中的Url.Action不會引起事件
<a href="@Url.Action("Index","Category", new { id = item.Id })">
它根本不會引發事件。我在這裏做錯了什麼?
@helper ShowTree(IEnumerable<FrontEnd.Controllers.SharedController.Category> categories)
{
<ul id="@(Added == false ? "categories" : "")" class="parent-1">
@foreach (FrontEnd.Controllers.SharedController.Category item in categories)
{
Added = true;
<li class="child-1 has-sublist">
<a href="@Url.Action("Index","Category", new { id = item.Id })">
@item.CategoryName
@if (item.Children.Count > 0)
{ <span>
[@item.Children.Count]
</span>
}
</a>
@if (item.Children.Any())
{
@ShowTree(item.Children)
}
</li>
}
</ul>
}
什麼「事件」你指的是?要轉到您的Action方法中指定的另一個URL? –
你的控制器被擊中了嗎?你有任何錯誤或例外嗎?我所指的控制器是「Listing」控制器(正如你的Url.Action所指定的) –
@Ahmedilyas是的,我的意思是,我的意思是發給控制器。 e.preventDefault();包含的JavaScript阻止了請求。 – OrElse