【发布时间】:2014-07-11 03:23:22
【问题描述】:
我有:
<p><a class="btn btn-default" href="~/Person">List of Cients &raquo;</a></p>
我想用 HTML Action Link 替换它,但不要更改视觉样式。
我想去IndexPersonController的操作:
公共类 PersonController : 控制器 { 私有 PersonContext db = new PersonContext();
// GET: Person
public ActionResult Index()
{
return View(db.Persons.ToList());
}
}
@Html.ActionLink(...) 应该是什么样子。
编辑:
我试过了:
<p><a class="btn btn-default" href="~/Person">List of Cients »</a></p>
@Html.ActionLink("List of Clients »", "Index", "Person", new { @class = "btn btn-default" })
有问题:&raquo; ActionLink 不呈现漂亮的箭头。
EDIT2:
试过了,没有结果:@Html.ActionLink("List of Clients " + HttpUtility.HtmlDecode("&raquo"), "Index", "Person", new { @class = "btn btn-default" })
编辑: 两者都不起作用。
<p> @Html.ActionLink("List of Clients »", "Index", "Person", new { @class = "btn btn-default" })</p>
<p> @(Html.ActionLink("List of Clients »", "PersonController/Index", new { @class = "btn btn-default" }));
首先给出正确的样式,但是当我单击时,我在链接中得到length=6。
第二个没有样式和链接:http://localhost:17697/Home/PersonController/Index?class=btn%20btn-default
回答:这个有效:
<p> @Html.ActionLink("List of Clients »", "Index", "Person", null, new { @class = "btn btn-default" })</p>
【问题讨论】:
标签: html css asp.net-mvc razor actionlink