gpt4 book ai didi

html - 如何将 CSS 类应用于 Razor 中的 HTML 操作链接

转载 作者:行者123 更新时间:2023-11-28 12:47:52 25 4
gpt4 key购买 nike

我有:

<p><a class="btn btn-default" href="~/Person">List of Cients &raquo;</a></p>

我想用 HTML Action Link 替换它,但不改变视觉样式。

我想去 Index PersonController的 Action :

公共(public)类 PersonController : Controller { private 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 &raquo;</a></p>
@Html.ActionLink("List of Clients &raquo", "Index", "Person", new { @class = "btn btn-default" })

问题在于:&raquo; ActionLink 不呈现漂亮的箭头。

编辑2:

试过没有结果:@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.ActionLink("Title", "/PersonController/Index", new { @class = "myCssClass"}));

这里有一个链接供引用:http://msdn.microsoft.com/en-us/library/dd492124(v=vs.108).aspx

关于html - 如何将 CSS 类应用于 Razor 中的 HTML 操作链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24689578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com