如何用@ Html.ActionLink中的glyphicon替换actionlink文本?

Rav*_*eja 2 asp.net asp.net-mvc twitter-bootstrap glyphicons twitter-bootstrap-3

我想替换Xglyphicon-trash.

X用作linktext.Which用于删除项目.如何用glyphicon替换.

这是我的代码

 @Html.ActionLink(
                     "X",
                     "Delete",
                     "Grocery",
                     new { GroceryUsageID = item.GroceryUsageID, GroceryId = item.GroceryID },
                     new { @onclick = "return confirm('Are you sure you want to delete this Grocery');"})
Run Code Online (Sandbox Code Playgroud)

Ibr*_*han 7

你可以像下面这样做.只需添加@class = "glyphicon glyphicon-trash"htmlAttributes参数和替换Xspace.

 @Html.ActionLink(
        " ",
        "Delete",
        "Grocery",
        new { GroceryUsageID = item.GroceryUsageID, GroceryId = item.GroceryID },
        new { @onclick = "return confirm('Are you sure you want to delete this Grocery');", 
              @class = "glyphicon glyphicon-trash" })
Run Code Online (Sandbox Code Playgroud)