user1893874
user1893874

Reputation: 843

How to display ActionLink with | symbol

I want to create a group of Actionlink and have control on that. Like

Add | Edit | Delete

I tried it as

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>
     ) 

I added "|" at the end of ActionLink but it is giving me error - Unexpected Token.

If status = ERROR then I want to display as Add | Detail | Delete if not then only Detail

Please suggest me how to do this.

Upvotes: 0

Views: 620

Answers (1)

Thiago Ferreira
Thiago Ferreira

Reputation: 651

It will work if you put '|' inside a <text> tag.

Like this:

<text>|</text>

Exemple with your code:

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

You can use @:| too. This way the pipe character will be read as server code and will print the '|' character without any problems.

Upvotes: 1

Related Questions