Actionlink没有在asp.net mvc视图中拾取Bootstrap按钮类
本文关键字:Bootstrap 按钮 视图 mvc asp net Actionlink | 更新日期: 2023-09-27 18:10:27
嗨,有没有人能快速浏览一下附件,看看为什么按钮不能正确地拾取引导类
所讨论的Actionlink项位于视图的最末尾。
我已经尝试将@section scripts部分移动到页面的不同部分,但没有任何区别。
谢谢约翰。
@model IEnumerable<IWA_Mileage_Tracker_Demo.Models.Journey>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.StartAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.FinishAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.DateofJourney)
</th>
<th>
@Html.DisplayNameFor(model => model.distance)
</th>
<th>
@Html.DisplayNameFor(model => model.ReasonForJourney)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.StartAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.FinishAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateofJourney)
</td>
<td>
@Html.DisplayFor(modelItem => item.distance)
</td>
<td>
@Html.DisplayFor(modelItem => item.ReasonForJourney)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
</table>
<div class="col-md-6">
@Html.ActionLink("Add a new journey", "Create", new {@class = "btn btn-default"})
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Html的第三个参数。ActionLink代表routeValues。如果你想添加html属性(和一些特定的类),你必须使用另一个重载:
@Html.ActionLink(string linkText, string actionName, object routeValues, object htmlAttributes)
对于你的情况,你可以传递空对象或null为routeValues,它将是:
@Html.ActionLink("Add a new journey", "Create", null, new { @class = "btn btn-default"})