在ASP的最新(RC1)版本中。NET MVC,我怎么得到Html。ActionLink渲染为按钮或图像而不是链接?


当前回答

你不能用Html.ActionLink这样做。你应该使用Url。RouteUrl并使用该URL来构造所需的元素。

其他回答

你不能用Html.ActionLink这样做。你应该使用Url。RouteUrl并使用该URL来构造所需的元素。

@using (Html.BeginForm("DeleteMember", "Member", new { id = Model.MemberID }))
    {
        <input type="submit" value="Delete Member" onclick = "return confirm('Are you sure you want to delete the member?');" />
    }

对于Material Design Lite和MVC:

<a class="mdl-navigation__link" href='@Url.Action("MyAction", "MyController")'>Link Name</a>

使用FORMACTION

<input type="submit" value="Delete" formaction="@Url.Action("Delete", new { id = Model.Id })" />

按照Mehrdad说的去做——或者像Stephen Walther在这里描述的那样,使用HtmlHelper扩展方法中的url helper,并创建自己的扩展方法,可以用来呈现所有的链接。

然后它将很容易渲染所有链接作为按钮/锚或任何你喜欢的-而且,最重要的是,你可以改变你的想法,当你发现你实际上更喜欢一些其他的方式制作你的链接。