2016-03-03 37 views
0

我想創建一組動作鏈接並對其進行控制。像如何使用|顯示ActionLink符號

添加|編輯|刪除

我想它作爲

grid.Column(header: "Payload Actions", format:   
     @<text> 
      @if (item.Status == "ERROR") 
      { 
       @Html.ActionLink("Add", "Add", "THRecovery", new {item.id}, new {@class = "addAction", @style = "color:blue;"}) | 
       @Html.ActionLink("Detail", "Detail", "THRecovery", new {item.id}, new {@class = "detailAction", @style = "color:blue;"}) | 
       @Html.ActionLink("Delete", "Delete", "THRecovery", new { item.id }, new { @class = "deleteAction", @style = "color:blue;" }) 
      }    
      @if (item.Status != "ERROR") 
      { 
       @Html.ActionLink("Details", "Details", "THRecovery", new {item.id}, new {@class = "detailAction", @style = "color:blue;"}) 
      }     
     </text> 
    ) 

我加入 「|」在ActionLink的結尾,但它給我錯誤 - 意外的令牌。

如果status = ERROR,那麼我想顯示爲Add |詳細信息|刪除 如果不是那麼只詳細

請告訴我如何做到這一點。

回答

1

它會工作,如果你把'|'在<text>標籤內。

像這樣:

<text>|</text> 

爲例你的代碼:

@Html.ActionLink("Add", "Add", "THRecovery", new {item.id}, new {@class = "addAction", @style = "color:blue;"}) <text>|</text> 

可以使用@:|了。這樣管道字符將被讀取爲服務器代碼並將打印'|'性格沒有任何問題。

+1

非常感謝您快速回答 – user1893874